Equalizer 1.0
|
00001 00002 /* Copyright (c) 2005-2011, Stefan Eilemann <eile@equalizergraphics.com> 00003 * 2010, Cedric Stalder <cedric Stalder@gmail.com> 00004 * 00005 * This library is free software; you can redistribute it and/or modify it under 00006 * the terms of the GNU Lesser General Public License version 2.1 as published 00007 * by the Free Software Foundation. 00008 * 00009 * This library is distributed in the hope that it will be useful, but WITHOUT 00010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00011 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00012 * details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public License 00015 * along with this library; if not, write to the Free Software Foundation, Inc., 00016 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00017 */ 00018 00019 #ifndef EQFABRIC_CONFIG_H 00020 #define EQFABRIC_CONFIG_H 00021 00022 #include <eq/fabric/api.h> 00023 #include <eq/fabric/types.h> // typedefs 00024 #include <eq/fabric/visitorResult.h> // enum 00025 #include <eq/fabric/object.h> // DIRTY_CUSTOM enum 00026 00027 namespace eq 00028 { 00029 namespace fabric 00030 { 00031 struct CanvasPath; 00032 struct LayoutPath; 00033 struct ObserverPath; 00034 00036 template< class S, class C, class O, class L, class CV, class N, class V > 00037 class Config : public Object 00038 { 00039 public: 00040 typedef std::vector< O* > Observers; 00041 typedef std::vector< L* > Layouts; 00042 typedef std::vector< CV* > Canvases; 00043 typedef std::vector< N* > Nodes; 00044 00048 EQFABRIC_INL co::base::RefPtr< S > getServer(); 00049 00051 EQFABRIC_INL co::base::RefPtr< const S > getServer() const; 00052 00054 const Observers& getObservers() const { return _observers; } 00055 00057 const Layouts& getLayouts() const { return _layouts; } 00058 00060 const Canvases& getCanvases() const { return _canvases; } 00061 00066 const Nodes& getNodes() const { return _nodes; } 00067 00075 EQFABRIC_INL VisitorResult accept( V& visitor ); 00076 00078 EQFABRIC_INL VisitorResult accept( V& visitor ) const; 00079 00081 template< typename T > EQFABRIC_INL T* find( const uint128_t& id ); 00082 00084 template< typename T > 00085 EQFABRIC_INL const T* find( const uint128_t& id ) const; 00086 00088 template< typename T > 00089 EQFABRIC_INL T* find( const std::string& name ); 00090 00092 template< typename T > 00093 EQFABRIC_INL const T* find( const std::string& name ) const; 00094 00096 O* getObserver( const ObserverPath& path ); 00097 00099 L* getLayout( const LayoutPath& path ); 00100 00102 CV* getCanvas( const CanvasPath& path ); 00103 00105 template< typename T > void find( const uint128_t& id, T** result ); 00106 00108 template< typename T > void find( const std::string& name, 00109 const T** result ) const; 00110 00112 virtual void updateCanvas( CV* ) { /* NOP */ } 00113 00115 virtual void exitCanvas( CV* ) { /* NOP */ } 00117 00120 // Note: also update string array initialization in config.ipp 00121 00123 enum FAttribute 00124 { 00125 FATTR_EYE_BASE, 00126 FATTR_VERSION, 00127 FATTR_LAST, 00128 FATTR_ALL = FATTR_LAST + 5 00129 }; 00130 00132 enum IAttribute 00133 { 00134 IATTR_ROBUSTNESS, 00135 IATTR_LAST, 00136 IATTR_ALL = IATTR_LAST + 5 00137 }; 00138 00140 void setFAttribute( const FAttribute attr, const float value ) 00141 { _fAttributes[attr] = value; } 00143 void setIAttribute( const IAttribute attr, const int32_t value ) 00144 { _iAttributes[attr] = value; } 00145 00147 float getFAttribute( const FAttribute attr ) const 00148 { return _fAttributes[attr]; } 00149 00151 int32_t getIAttribute( const IAttribute attr ) const 00152 { return _iAttributes[attr]; } 00153 00155 static const std::string& getFAttributeString( const FAttribute attr ); 00157 static const std::string& getIAttributeString( const IAttribute attr ); 00159 00160 00174 virtual void setLatency( const uint32_t latency ); 00175 00177 uint32_t getLatency() const { return _data.latency; } 00178 00180 EQFABRIC_INL virtual void restore(); 00182 00183 virtual void output( std::ostream& ) const {} 00184 void create( O** observer ); 00185 void release( O* observer ); 00186 void create( L** layout ); 00187 void release( L* layout ); 00188 void create( CV** canvas ); 00189 void release( CV* canvas ); 00190 void create( N** node ); 00191 void release( N* node ); 00192 00193 protected: 00195 EQFABRIC_INL Config( co::base::RefPtr< S > parent ); 00196 00198 EQFABRIC_INL virtual ~Config(); 00199 00201 EQFABRIC_INL virtual void attach( const co::base::UUID& id, 00202 const uint32_t instanceID ); 00203 00205 EQFABRIC_INL virtual void serialize( co::DataOStream& os, 00206 const uint64_t dirtyBits ); 00207 EQFABRIC_INL virtual void deserialize( co::DataIStream& is, 00208 const uint64_t dirtyBits ); 00209 EQFABRIC_INL virtual void notifyDetach(); 00210 00212 virtual void _removeChild( const co::base::UUID& ) 00213 { EQUNIMPLEMENTED; } 00214 00215 template< class, class, class, class, class > friend class Server; 00216 00217 void setAppNodeID( const co::NodeID& nodeID ); 00218 00219 const co::NodeID& getAppNodeID() const { return _appNodeID; } 00220 00221 virtual void changeLatency( const uint32_t ) { /* NOP */ } 00222 virtual bool mapViewObjects() const { return false; } 00223 virtual bool mapNodeObjects() const { return false; } 00224 00226 EQFABRIC_INL uint128_t commit( const uint32_t incarnation ); 00227 00229 virtual VisitorResult _acceptCompounds( V& ) 00230 { return TRAVERSE_CONTINUE; } 00232 virtual VisitorResult _acceptCompounds( V& ) const 00233 { return TRAVERSE_CONTINUE; } 00234 template< class C2, class V2 > 00235 friend VisitorResult _acceptImpl( C2*, V2& ); 00236 00237 N* _findNode( const uint128_t& id ); 00238 00239 00240 private: 00241 00243 co::base::RefPtr< S > _server; 00244 00246 float _fAttributes[FATTR_ALL]; 00247 00249 int32_t _iAttributes[IATTR_ALL]; 00250 00252 Observers _observers; 00253 00255 Layouts _layouts; 00256 00258 Canvases _canvases; 00259 00261 Nodes _nodes; 00262 00264 co::NodeID _appNodeID; 00265 00266 struct BackupData 00267 { 00268 BackupData() : latency( 1 ) {} 00269 00271 uint32_t latency; 00272 } 00273 _data, _backup; 00274 00275 struct Private; 00276 Private* _private; // placeholder for binary-compatible changes 00277 00278 enum DirtyBits 00279 { 00280 DIRTY_MEMBER = Object::DIRTY_CUSTOM << 0, 00281 DIRTY_LATENCY = Object::DIRTY_CUSTOM << 1, 00282 DIRTY_ATTRIBUTES = Object::DIRTY_CUSTOM << 2, 00283 DIRTY_NODES = Object::DIRTY_CUSTOM << 3, 00284 DIRTY_OBSERVERS = Object::DIRTY_CUSTOM << 4, 00285 DIRTY_LAYOUTS = Object::DIRTY_CUSTOM << 5, 00286 DIRTY_CANVASES = Object::DIRTY_CUSTOM << 6, 00287 DIRTY_CONFIG_BITS = 00288 DIRTY_MEMBER | DIRTY_ATTRIBUTES | DIRTY_OBSERVERS | 00289 DIRTY_LAYOUTS | DIRTY_CANVASES | DIRTY_NODES | DIRTY_LATENCY 00290 }; 00291 00293 virtual uint64_t getRedistributableBits() const 00294 { return DIRTY_CONFIG_BITS; } 00295 00297 EQFABRIC_INL virtual uint32_t commitNB( const uint32_t incarnation ); 00298 00299 template< class, class > friend class Observer; 00300 void _addObserver( O* observer ); 00301 bool _removeObserver( O* observer ); 00302 00303 template< class, class, class > friend class Layout; 00304 void _addLayout( L* layout ); 00305 bool _removeLayout( L* layout ); 00306 00307 template< class, class, class, class > friend class Canvas; 00308 void _addCanvas( CV* canvas ); 00309 bool _removeCanvas( CV* canvas ); 00310 00311 template< class, class, class, class > friend class Node; 00312 void _addNode( N* node ); 00313 EQFABRIC_INL bool _removeNode( N* node ); 00314 00315 typedef co::CommandFunc< Config< S, C, O, L, CV, N, V > > CmdFunc; 00316 bool _cmdNewLayout( co::Command& command ); 00317 bool _cmdNewCanvas( co::Command& command ); 00318 bool _cmdNewObserver( co::Command& command ); 00319 bool _cmdNewEntityReply( co::Command& command ); 00320 }; 00321 00322 template< class S, class C, class O, class L, class CV, class N, class V > 00323 EQFABRIC_INL std::ostream& operator << ( std::ostream& os, 00324 const Config< S, C, O, L, CV, N, V >& config ); 00325 } 00326 } 00327 #endif // EQFABRIC_CONFIG_H