Robot Devastation
ImageManager.hpp
1 // Authors: see AUTHORS.md at project root.
2 // CopyPolicy: released under the terms of the LGPLv2.1, see LICENSE at project root.
3 // URL: https://github.com/asrob-uc3m/robotDevastation
4 
5 #ifndef __RD_IMAGE_MANAGER_HPP__
6 #define __RD_IMAGE_MANAGER_HPP__
7 
8 #include <vector>
9 #include <map>
10 #include <string>
11 
12 #include <yarp/sig/Image.h>
13 
14 #include "ImageEventListener.hpp"
15 
16 namespace rd{
17 
18 typedef yarp::sig::ImageOf<yarp::sig::PixelRgb> Image;
19 
20 class ImageEventListener; //-- Required to avoid recurrent loops in dependencies
21 
40 {
41  public:
42  //------------------------------ Construction & destruction ---------------------------------------------------//
48  static ImageManager *getImageManager();
49 
55  static ImageManager * getImageManager(const std::string & id);
56 
58  static bool destroyImageManager();
59 
60  virtual ~ImageManager();
61 
62 
63  //------------------------------ Manager Startup & Halting ----------------------------------------------------//
69  virtual bool start() = 0;
70 
72  virtual bool stop() = 0;
73 
75  virtual bool isStopped() const = 0;
76 
78  virtual bool setEnabled(bool enabled) = 0;
79 
80  //------------------------------- Read image ------------------------------------------------------------------//
82  virtual Image getImage() const = 0;
83 
84 
85  //------------------------------ Configuration & Listeners ----------------------------------------------------//
87  bool addImageEventListener( ImageEventListener * listener );
90 
92  virtual bool configure(const std::string & parameter, const std::string & value);
93 
94 
95  protected:
100  static bool Register( ImageManager * manager, const std::string & id);
101 
103  std::vector<ImageEventListener *> listeners;
104 
105  private:
108 
110  static std::string currentId;
111 
113  static std::map< std::string, ImageManager * > imageManagerRegistry;
114 
115 
116 };
117 
118 }
119 
120 #endif //-- __RD_IMAGE_MANAGER_HPP__
rd::ImageManager::stop
virtual bool stop()=0
Stop capturing images.
rd::ImageManager::setEnabled
virtual bool setEnabled(bool enabled)=0
Enables/disables notifications to listeners.
rd::ImageManager::imageManagerInstance
static ImageManager * imageManagerInstance
Stores the unique instance of the InputManager.
Definition: ImageManager.hpp:107
rd::ImageEventListener
Interface for objects that can be notified of events related to images.
Definition: ImageEventListener.hpp:21
rd::ImageManager::imageManagerRegistry
static std::map< std::string, ImageManager * > imageManagerRegistry
Stores all the ImageManager that have been registered.
Definition: ImageManager.hpp:113
rd
The main, catch-all namespace for Robot Devastation.
Definition: groups.dox:4
rd::ImageManager::listeners
std::vector< ImageEventListener * > listeners
Observers registered to be notified of image events.
Definition: ImageManager.hpp:103
rd::ImageManager::isStopped
virtual bool isStopped() const =0
True if the manager is not active.
rd::ImageManager::getImageManager
static ImageManager * getImageManager()
Get a reference to the ImageManager.
Definition: ImageManager.cpp:16
rd::ImageManager::destroyImageManager
static bool destroyImageManager()
Deallocate all the registered ImageManager.
Definition: ImageManager.cpp:53
rd::ImageManager::Register
static bool Register(ImageManager *manager, const std::string &id)
This function allows subclasses to install their unique instances in the singleton register to be sel...
Definition: ImageManager.cpp:113
rd::ImageManager::addImageEventListener
bool addImageEventListener(ImageEventListener *listener)
Adds a ImageEventListener to the list of observers to be notified of events.
Definition: ImageManager.cpp:96
rd::ImageManager::currentId
static std::string currentId
Stores the id of the current unique instance used.
Definition: ImageManager.hpp:110
rd::ImageManager::configure
virtual bool configure(const std::string &parameter, const std::string &value)
Configures a parameter with a value.
Definition: ImageManager.cpp:108
rd::ImageManager::removeImageEventListeners
bool removeImageEventListeners()
Unregisters all the ImageEventListener stored.
Definition: ImageManager.cpp:102
rd::ImageManager::start
virtual bool start()=0
Start to capture images.
rd::ImageManager
Generic image input manager.
Definition: ImageManager.hpp:39
rd::ImageManager::getImage
virtual Image getImage() const =0
Return the last received image.