00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef WMODULEOUTPUTDATA_H
00026 #define WMODULEOUTPUTDATA_H
00027
00028 #include <string>
00029
00030 #include <boost/shared_ptr.hpp>
00031
00032 #include "../common/WLogger.h"
00033
00034
00035 template < typename T > class WModuleInputData;
00036 #include "WModuleInputData.h"
00037 #include "../common/WPrototyped.h"
00038 #include "../common/WTransferable.h"
00039
00040 #include "WModuleOutputConnector.h"
00041
00042
00043
00044
00045
00046 template < typename T >
00047 class WModuleOutputData: public WModuleOutputConnector
00048 {
00049 public:
00050
00051
00052
00053 typedef boost::shared_ptr< WModuleOutputData< T > > PtrType;
00054
00055
00056
00057
00058 typedef WModuleOutputData< T >& RefType;
00059
00060
00061
00062
00063 typedef WModuleOutputData< T > Type;
00064
00065
00066
00067
00068 typedef T TransferType;
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079 static PtrType create( boost::shared_ptr< WModule > module, std::string name = "", std::string description = "" );
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091 static PtrType createAndAdd( boost::shared_ptr< WModule > module, std::string name = "", std::string description = "" );
00092
00093
00094
00095
00096
00097
00098
00099
00100 WModuleOutputData( boost::shared_ptr< WModule > module, std::string name = "", std::string description = "" )
00101 :WModuleOutputConnector( module, name, description )
00102 {
00103 m_data = boost::shared_ptr< T >();
00104 };
00105
00106
00107
00108
00109 virtual ~WModuleOutputData()
00110 {
00111 };
00112
00113
00114
00115
00116
00117
00118 virtual void updateData( boost::shared_ptr< T > data )
00119 {
00120 m_data = data;
00121
00122
00123 triggerUpdate();
00124 };
00125
00126
00127
00128
00129 virtual void reset()
00130 {
00131 updateData( boost::shared_ptr< T >() );
00132 }
00133
00134
00135
00136
00137 virtual void triggerUpdate()
00138 {
00139
00140 propagateDataChange();
00141 };
00142
00143
00144
00145
00146
00147
00148 virtual const boost::shared_ptr< WTransferable > getRawData() const
00149 {
00150 return m_data;
00151 };
00152
00153
00154
00155
00156
00157
00158 const boost::shared_ptr< T > getData() const
00159 {
00160 return m_data;
00161 };
00162
00163
00164
00165
00166
00167
00168
00169
00170 virtual bool connectable( boost::shared_ptr<WModuleConnector> con )
00171 {
00172
00173 return WModuleOutputConnector::connectable( con );
00174 };
00175
00176
00177
00178
00179
00180
00181 virtual boost::shared_ptr< WPrototyped > getTransferPrototype()
00182 {
00183
00184 return ( m_data == boost::shared_ptr< T >() ) ? T::getPrototype() : boost::shared_static_cast< WPrototyped >( m_data );
00185 };
00186
00187 protected:
00188
00189 private:
00190
00191
00192
00193
00194 boost::shared_ptr< T > m_data;
00195 };
00196
00197 template < typename T >
00198 typename WModuleOutputData< T >::PtrType WModuleOutputData< T >::create( boost::shared_ptr< WModule > module, std::string name,
00199 std::string description )
00200 {
00201 typedef typename WModuleOutputData< T >::PtrType PTR;
00202 typedef typename WModuleOutputData< T >::Type TYPE;
00203 return PTR( new TYPE( module, name, description ) );
00204 }
00205
00206 template < typename T >
00207 typename WModuleOutputData< T >::PtrType WModuleOutputData< T >::createAndAdd( boost::shared_ptr< WModule > module, std::string name,
00208 std::string description )
00209 {
00210 typename WModuleOutputData< T >::PtrType c = create( module, name, description );
00211 module->addConnector( c );
00212 return c;
00213 }
00214
00215 #endif // WMODULEOUTPUTDATA_H
00216