Changeset 13 in flair-dev for trunk/include/FlairCore/IODevice.h
- Timestamp:
- 04/08/16 15:39:24 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/FlairCore/IODevice.h
r2 r13 20 20 class FrameworkManager_impl; 21 21 22 namespace flair { namespace core { 22 namespace flair { 23 namespace core { 23 24 24 25 25 class io_data; 26 class DataType; 26 27 27 /*! \class IODevice 28 * 29 * \brief Abstract class for input/ouput system 30 * 31 * An input/output system is generally used to describe a sensor, an actuator or a filter. \n 32 * These systems can be linked (for exemple a sensor with a filter), when an IODevice 33 * is created with a parent of type IODevice. 34 * In this case, an update of the parent's data will call an update 35 * of the child's data (for exemple when a sensor gets new datas, a filter is automatically called). \n 36 * Output of this object can also be sent to a shared memory using the OutputToShMem method; in order to use it with an 37 * external program. 38 */ 39 class IODevice: public Object { 40 friend class ::IODevice_impl; 41 friend class ::Thread_impl; 42 friend class ::FrameworkManager_impl; 28 /*! \class IODevice 29 * 30 * \brief Abstract class for input/ouput system 31 * 32 * An input/output system is generally used to describe a sensor, an actuator or 33 *a filter. \n 34 * These systems can be linked (for exemple a sensor with a filter), when an 35 *IODevice 36 * is created with a parent of type IODevice. 37 * In this case, an update of the parent's data will call an update 38 * of the child's data (for exemple when a sensor gets new datas, a filter is 39 *automatically called). \n 40 * Output of this object can also be sent to a shared memory using the 41 *OutputToShMem method; in order to use it with an 42 * external program. 43 */ 44 class IODevice : public Object { 45 friend class ::IODevice_impl; 46 friend class ::Thread_impl; 47 friend class ::FrameworkManager_impl; 43 48 44 public: 45 /*! 46 * \brief Constructor 47 * 48 * Construct an IODevice of Object's type "IODevice" (see Object::ObjectType). \n 49 * If parent's Object::ObjectType is also "IODevice", this IODevice will be linked to its parent 50 * (see ProcessUpdate()). 51 * 52 * \param parent parent 53 * \param name name 54 */ 55 IODevice(const Object* parent,std::string name); 49 public: 50 /*! 51 * \brief Constructor 52 * 53 * Construct an IODevice of Object's type "IODevice" (see Object::ObjectType). 54 *\n 55 * If parent's Object::ObjectType is also "IODevice", this IODevice will be 56 *linked to its parent 57 * (see ProcessUpdate()). 58 * 59 * \param parent parent 60 * \param name name 61 */ 62 IODevice(const Object *parent, std::string name); 56 63 57 58 59 60 61 64 /*! 65 * \brief Destructor 66 * 67 */ 68 virtual ~IODevice(); 62 69 63 64 65 66 67 68 69 70 71 72 73 74 75 76 void AddDeviceToLog(const IODevice*device);70 /*! 71 * \brief Add an IODevice to the logs 72 * 73 * The IODevice will be automatically logged among this IODevice logs, 74 * if logging is enabled (see SetDataToLog(), FrameworkManager::StartLog 75 * and FrameworkManager::AddDeviceToLog). \n 76 * Logging happens when ProcessUpdate() is called. \n 77 * Note that when an IODevice is just added for logs (ie. no parent/child 78 * link between the two IODevice), 79 * UpdateFrom() is not automatically called. 80 * 81 * \param device IODevice to log 82 */ 83 void AddDeviceToLog(const IODevice *device); 77 84 78 /*! 79 * \brief Add an io_data to the log 80 * 81 * The io_data will be automatically logged if enabled (see FrameworkManager::StartLog 82 * and FrameworkManager::AddDeviceToLog), 83 * during call to ProcessUpdate(). 84 * 85 * \param data data to log 86 */ 87 void AddDataToLog(const io_data* data); 85 /*! 86 * \brief Add an io_data to the log 87 * 88 * The io_data will be automatically logged if enabled (see 89 *FrameworkManager::StartLog 90 * and FrameworkManager::AddDeviceToLog), 91 * during call to ProcessUpdate(). 92 * 93 * \param data data to log 94 */ 95 void AddDataToLog(const io_data *data); 88 96 89 90 91 92 93 94 95 96 97 98 99 100 101 102 97 /*! 98 * \brief Send the output to a shared memory 99 * 100 * Use this method to output log datas to a shared memory. 101 * This can be usefull to get datas from an external progam. \n 102 * Output happens when ProcessUpdate() is called. \n 103 * The name and the structure of the shared memory will be displayed when 104 * this method is called with true as argument. \n 105 * By default it is not enabled. 106 * 107 * 108 * \param enabled true to enable the output, false otherwise 109 */ 110 void OutputToShMem(bool enabled); 103 111 104 //TODO: these 2 method should be pure virtual105 106 112 // TODO: these 2 method should be pure virtual 113 virtual DataType const &GetInputDataType() const; 114 virtual DataType const &GetOutputDataType() const; 107 115 108 protected: 109 /*! 110 * \brief Process the childs of type IODevice, and log if needed 111 * 112 * This method must be called after computing datas; 113 * generally at the end of the reimplemented UpdateFrom or after acquiring datas in case of a sensor. \n 114 * It will call UpdateFrom methods of each child of type IODevice, 115 * and log all datas (this IODevice and its childs) 116 * if logging is enabled (see SetDataToLog(), AddDeviceToLog(), 117 * FrameworkManager::StartLog and FrameworkManager::AddDeviceToLog). \n 118 * If a thread is waiting on this IODevice (see Thread::WaitUpdate), it will be resumed. 119 * 120 * \param data data to process 121 */ 122 void ProcessUpdate(io_data* data); 116 protected: 117 /*! 118 * \brief Process the childs of type IODevice, and log if needed 119 * 120 * This method must be called after computing datas; 121 * generally at the end of the reimplemented UpdateFrom or after acquiring 122 *datas in case of a sensor. \n 123 * It will call UpdateFrom methods of each child of type IODevice, 124 * and log all datas (this IODevice and its childs) 125 * if logging is enabled (see SetDataToLog(), AddDeviceToLog(), 126 * FrameworkManager::StartLog and FrameworkManager::AddDeviceToLog). \n 127 * If a thread is waiting on this IODevice (see Thread::WaitUpdate), it will be 128 *resumed. 129 * 130 * \param data data to process 131 */ 132 void ProcessUpdate(io_data *data); 123 133 124 private: 125 /*! 126 * \brief Update using provided datas 127 * 128 * This method is automatically called by ProcessUpdate() 129 * of the Object::Parent's if its Object::ObjectType is "IODevice". \n 130 * This method must be reimplemented, in order to process the data from the parent. 131 * 132 * \param data data from the parent to process 133 */ 134 virtual void UpdateFrom(const io_data *data)=0; 134 private: 135 /*! 136 * \brief Update using provided datas 137 * 138 * This method is automatically called by ProcessUpdate() 139 * of the Object::Parent's if its Object::ObjectType is "IODevice". \n 140 * This method must be reimplemented, in order to process the data from the 141 *parent. 142 * 143 * \param data data from the parent to process 144 */ 145 virtual void UpdateFrom(const io_data *data) = 0; 135 146 136 class IODevice_impl*pimpl_;137 147 class IODevice_impl *pimpl_; 148 }; 138 149 139 150 } // end namespace core
Note:
See TracChangeset
for help on using the changeset viewer.