Equalizer  1.4.1
include/eq/fabric/config.h
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 {
00032     template< class S, class C, class O, class L, class CV, class N, class V >
00033     class Config : public Object
00034     {
00035     public:
00036         typedef std::vector< O* >  Observers; 
00037         typedef std::vector< L* >  Layouts;   
00038         typedef std::vector< CV* > Canvases;  
00039         typedef std::vector< N* >  Nodes;     
00040 
00044         EQFABRIC_INL lunchbox::RefPtr< S > getServer();
00045 
00047         EQFABRIC_INL lunchbox::RefPtr< const S > getServer() const;
00048 
00050         const Observers& getObservers() const { return _observers; }
00051 
00053         const Layouts& getLayouts() const { return _layouts; }
00054 
00056         const Canvases& getCanvases() const { return _canvases; }
00057 
00062         EQFABRIC_INL uint32_t getTimeout() const;
00063 
00068         const Nodes& getNodes() const { return _nodes; }
00069 
00070         EQFABRIC_INL N* findAppNode(); 
00071         EQFABRIC_INL const N* findAppNode() const; 
00072 
00080         EQFABRIC_INL VisitorResult accept( V& visitor );
00081 
00083         EQFABRIC_INL VisitorResult accept( V& visitor ) const;
00084 
00086         template< typename T > EQFABRIC_INL T* find( const uint128_t& id );
00087 
00089         template< typename T >
00090         EQFABRIC_INL const T* find( const uint128_t& id ) const;
00091 
00093         template< typename T >
00094         EQFABRIC_INL T* find( const std::string& name );
00095 
00097         template< typename T >
00098         EQFABRIC_INL const T* find( const std::string& name ) const;
00099 
00101         O* getObserver( const ObserverPath& path );
00102 
00104         L* getLayout( const LayoutPath& path );
00105 
00107         CV* getCanvas( const CanvasPath& path );
00108 
00110         template< typename T > void find( const uint128_t& id, T** result );
00111 
00113         template< typename T > void find( const std::string& name,
00114                                           const T** result ) const;
00115 
00117         virtual void updateCanvas( CV* ) { /* NOP */ }
00118 
00120         virtual void exitCanvas( CV* ) { /* NOP */ }
00122 
00125         // Note: also update string array initialization in config.ipp
00126 
00128         enum FAttribute
00129         {
00130             FATTR_EYE_BASE, 
00131             FATTR_VERSION,  
00132             FATTR_LAST,
00133             FATTR_ALL = FATTR_LAST + 5
00134         };
00135 
00137         enum IAttribute
00138         {
00139             IATTR_ROBUSTNESS, 
00140             IATTR_LAST,
00141             IATTR_ALL = IATTR_LAST + 5
00142         };
00143 
00145         void setFAttribute( const FAttribute attr, const float value )
00146             { _fAttributes[attr] = value; }
00148         void setIAttribute( const IAttribute attr, const int32_t value )
00149             { _iAttributes[attr] = value; }
00150 
00152         float getFAttribute( const FAttribute attr ) const
00153             { return _fAttributes[attr]; }
00154 
00156         int32_t getIAttribute( const IAttribute attr ) const
00157             { return _iAttributes[attr]; }
00158 
00160         static const std::string& getFAttributeString( const FAttribute attr );
00162         static const std::string& getIAttributeString( const IAttribute attr );
00164 
00165 
00179         virtual void setLatency( const uint32_t latency );
00180 
00182         uint32_t getLatency() const { return _data.latency; }
00183 
00185         EQFABRIC_INL virtual void restore();
00187 
00188         virtual void output( std::ostream& ) const {} 
00189         void create( O** observer ); 
00190         void release( O* observer ); 
00191         void create( L** layout );   
00192         void release( L* layout );   
00193         void create( CV** canvas );  
00194         void release( CV* canvas );  
00195         void create( N** node );     
00196         void release( N* node );     
00197 
00198     protected:
00200         EQFABRIC_INL Config( lunchbox::RefPtr< S > parent );
00201 
00203         EQFABRIC_INL virtual ~Config();
00204 
00206         EQFABRIC_INL virtual void attach( const UUID& id,
00207                                           const uint32_t instanceID );
00208 
00210         EQFABRIC_INL virtual void serialize( co::DataOStream& os,
00211                                              const uint64_t dirtyBits );
00212         EQFABRIC_INL virtual void deserialize( co::DataIStream& is,
00213                                                const uint64_t dirtyBits );
00214         EQFABRIC_INL virtual void notifyDetach();
00215 
00217         virtual void _removeChild( const UUID& )
00218             { LBUNIMPLEMENTED; }
00219 
00220         template< class, class, class, class, class, class >
00221         friend class Server;
00222 
00223         void setAppNodeID( const co::NodeID& nodeID ); 
00224 
00225         const co::NodeID& getAppNodeID() const { return _appNodeID; }
00226 
00227         virtual void changeLatency( const uint32_t ) { /* NOP */ }
00228         virtual bool mapViewObjects() const { return false; } 
00229         virtual bool mapNodeObjects() const { return false; } 
00230 
00232         virtual VisitorResult _acceptCompounds( V& )
00233             { return TRAVERSE_CONTINUE; }
00235         virtual VisitorResult _acceptCompounds( V& ) const
00236             { return TRAVERSE_CONTINUE; }
00237         template< class C2, class V2 >
00238         friend VisitorResult _acceptImpl( C2*, V2& );
00239 
00240         N* _findNode( const uint128_t& id ); 
00241 
00243         EQFABRIC_INL virtual uint128_t commit( const uint32_t incarnation =
00244                                                CO_COMMIT_NEXT );
00246 
00247     private:
00248 
00250         lunchbox::RefPtr< S > _server;
00251 
00253         float _fAttributes[FATTR_ALL];
00254 
00256         int32_t _iAttributes[IATTR_ALL];
00257 
00259         Observers _observers;
00260 
00262         Layouts _layouts;
00263 
00265         Canvases _canvases;
00266 
00268         Nodes _nodes;
00269 
00271         co::NodeID _appNodeID;
00272 
00273         struct BackupData
00274         {
00275             BackupData() : latency( 1 ) {}
00276 
00278             uint32_t latency;
00279         }
00280             _data, _backup;
00281 
00282         struct Private;
00283         Private* _private; // placeholder for binary-compatible changes
00284 
00285         enum DirtyBits
00286         {
00287             DIRTY_MEMBER     = Object::DIRTY_CUSTOM << 0,
00288             DIRTY_LATENCY    = Object::DIRTY_CUSTOM << 1,
00289             DIRTY_ATTRIBUTES = Object::DIRTY_CUSTOM << 2,
00290             DIRTY_NODES      = Object::DIRTY_CUSTOM << 3,
00291             DIRTY_OBSERVERS  = Object::DIRTY_CUSTOM << 4,
00292             DIRTY_LAYOUTS    = Object::DIRTY_CUSTOM << 5,
00293             DIRTY_CANVASES   = Object::DIRTY_CUSTOM << 6,
00294             DIRTY_CONFIG_BITS =
00295                 DIRTY_MEMBER | DIRTY_ATTRIBUTES | DIRTY_OBSERVERS |
00296                 DIRTY_LAYOUTS | DIRTY_CANVASES | DIRTY_NODES | DIRTY_LATENCY
00297         };
00298 
00300         virtual uint64_t getRedistributableBits() const
00301             { return DIRTY_CONFIG_BITS; }
00302 
00303         template< class, class > friend class Observer;
00304         void _addObserver( O* observer );
00305         bool _removeObserver( O* observer );
00306 
00307         template< class, class, class > friend class Layout;
00308         void _addLayout( L* layout );
00309         bool _removeLayout( L* layout );
00310 
00311         template< class, class, class, class > friend class Canvas;
00312         void _addCanvas( CV* canvas );
00313         bool _removeCanvas( CV* canvas );
00314 
00315         template< class, class, class, class > friend class Node;
00316         void _addNode( N* node );
00317         EQFABRIC_INL bool _removeNode( N* node );
00318 
00319         typedef co::CommandFunc< Config< S, C, O, L, CV, N, V > > CmdFunc;
00320         bool _cmdNewLayout( co::Command& command );
00321         bool _cmdNewCanvas( co::Command& command );
00322         bool _cmdNewObserver( co::Command& command );
00323         bool _cmdNewEntityReply( co::Command& command );
00324     };
00325 
00326     template< class S, class C, class O, class L, class CV, class N, class V >
00327     EQFABRIC_INL std::ostream& operator << ( std::ostream& os,
00328                                  const Config< S, C, O, L, CV, N, V >& config );
00329 }
00330 }
00331 #endif // EQFABRIC_CONFIG_H
Generated on Mon Nov 26 2012 14:41:48 for Equalizer 1.4.1 by  doxygen 1.7.6.1