source: flair-src/trunk/lib/FlairCore/src/IODevice.h@ 126

Last change on this file since 126 was 121, checked in by Sanahuja Guillaume, 8 years ago

modifs camera

File size: 4.4 KB
Line 
1// %flair:license{
2// This file is part of the Flair framework distributed under the
3// CECILL-C License, Version 1.0.
4// %flair:license}
5// ---
6/*!
7 * \file IODevice.h
8 * \brief Abstract class for input/ouput system
9 * \author Guillaume Sanahuja, Copyright Heudiasyc UMR UTC/CNRS 7253
10 * \date 2011/05/01
11 * \version 4.0
12 */
13
14#ifndef IO_DEVICE_H
15#define IO_DEVICE_H
16
17#include <Object.h>
18
19class IODevice_impl;
20class Thread_impl;
21class FrameworkManager_impl;
22
23namespace flair {
24namespace core {
25
26class io_data;
27class DataType;
28
29/*! \class IODevice
30*
31* \brief Abstract class for input/ouput system
32*
33* An input/output system is generally used to describe a sensor, an actuator or
34*a filter. \n
35* These systems can be linked (for exemple a sensor with a filter), when an
36*IODevice
37* is created with a parent of type IODevice.
38* In this case, an update of the parent's data will call an update
39* of the child's data (for exemple when a sensor gets new datas, a filter is
40*automatically called). \n
41* Output of this object can also be sent to a shared memory using the
42*OutputToShMem method; in order to use it with an
43* external program.
44*/
45class IODevice : public Object {
46 friend class ::IODevice_impl;
47 friend class ::Thread_impl;
48 friend class ::FrameworkManager_impl;
49
50public:
51 /*!
52 * \brief Constructor
53 *
54 * Construct an IODevice of Object's type "IODevice" (see Object::ObjectType).
55 *\n
56 * If parent's Object::ObjectType is also "IODevice", this IODevice will be
57 *linked to its parent
58 * (see ProcessUpdate()).
59 *
60 * \param parent parent
61 * \param name name
62 */
63 IODevice(const Object *parent, std::string name);
64
65 /*!
66 * \brief Destructor
67 *
68 */
69 virtual ~IODevice();
70
71 /*!
72 * \brief Add an IODevice to the logs
73 *
74 * The IODevice will be automatically logged among this IODevice logs,
75 * if logging is enabled (see SetDataToLog(), FrameworkManager::StartLog
76 * and FrameworkManager::AddDeviceToLog). \n
77 * Logging happens when ProcessUpdate() is called. \n
78 * Note that when an IODevice is just added for logs (ie. no parent/child
79 * link between the two IODevice),
80 * UpdateFrom() is not automatically called.
81 *
82 * \param device IODevice to log
83 */
84 void AddDeviceToLog(const IODevice *device);
85
86 /*!
87 * \brief Add an io_data to the log
88 *
89 * The io_data will be automatically logged if enabled (see
90 *FrameworkManager::StartLog
91 * and FrameworkManager::AddDeviceToLog),
92 * during call to ProcessUpdate().
93 *
94 * \param data data to log
95 */
96 void AddDataToLog(const io_data *data);
97
98 /*!
99 * \brief Send the output to a shared memory
100 *
101 * Use this method to output log datas to a shared memory.
102 * This can be usefull to get datas from an external progam. \n
103 * Output happens when ProcessUpdate() is called. \n
104 * The name and the structure of the shared memory will be displayed when
105 * this method is called with true as argument. \n
106 * By default it is not enabled.
107 *
108 *
109 * \param enabled true to enable the output, false otherwise
110 */
111 void OutputToShMem(bool enabled);
112
113 // TODO: these 2 method should be pure virtual
114 virtual DataType const &GetInputDataType() const;
115 virtual DataType const &GetOutputDataType() const;
116
117 protected:
118 /*!
119 * \brief Process the childs of type IODevice, and log if needed
120 *
121 * This method must be called after computing datas;
122 * generally at the end of the reimplemented UpdateFrom or after acquiring 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 resumed.
128 *
129 * \param data data to process
130 */
131 void ProcessUpdate(io_data* data);
132
133private:
134 /*!
135 * \brief Update using provided datas
136 *
137 * This method is automatically called by ProcessUpdate()
138 * of the Object::Parent's if its Object::ObjectType is "IODevice". \n
139 * This method must be reimplemented, in order to process the data from the
140 *parent.
141 *
142 * \param data data from the parent to process
143 */
144 virtual void UpdateFrom(const io_data *data) = 0;
145
146 class IODevice_impl *pimpl_;
147};
148
149} // end namespace core
150} // end namespace flair
151
152#endif // IO_DEVICE_H
Note: See TracBrowser for help on using the repository browser.