Equalizer  1.2.1
co/object.h
00001 
00002 /* Copyright (c) 2005-2012, Stefan Eilemann <eile@equalizergraphics.com> 
00003  *
00004  * This library is free software; you can redistribute it and/or modify it under
00005  * the terms of the GNU Lesser General Public License version 2.1 as published
00006  * by the Free Software Foundation.
00007  *  
00008  * This library is distributed in the hope that it will be useful, but WITHOUT
00009  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00010  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00011  * details.
00012  * 
00013  * You should have received a copy of the GNU Lesser General Public License
00014  * along with this library; if not, write to the Free Software Foundation, Inc.,
00015  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00016  */
00017 
00018 #ifndef CO_OBJECT_H
00019 #define CO_OBJECT_H
00020 
00021 #include <co/dispatcher.h>    // base class
00022 #include <co/localNode.h>     // used in RefPtr
00023 #include <co/types.h>         // for Nodes
00024 #include <co/version.h>       // used as default parameter
00025 
00026 namespace co
00027 {
00028     class ObjectCM;
00029 
00030 #  define CO_COMMIT_NEXT EQ_UNDEFINED_UINT32 //!< the next commit incarnation
00031 
00039     class Object : public Dispatcher
00040     {
00041     public:
00043         enum ChangeType
00044         {
00045             NONE,              
00046             STATIC,            
00047             INSTANCE,          
00048             DELTA,             
00049             UNBUFFERED,        
00050         };
00051 
00053         CO_API Object();
00054 
00056         CO_API virtual ~Object();
00057 
00061         bool isAttached() const { return _instanceID != EQ_INSTANCE_INVALID; }
00062 
00067         LocalNodePtr getLocalNode(){ return _localNode; };
00068 
00079         CO_API void setID( const base::UUID& identifier );
00080 
00082         const base::UUID& getID() const { return _id; }
00083 
00085         uint32_t getInstanceID() const { return _instanceID; }
00086 
00088         CO_API bool isBuffered() const;
00089 
00093         CO_API bool isMaster() const;
00095 
00099         virtual ChangeType getChangeType() const { return STATIC; }
00100 
00110         CO_API virtual uint32_t chooseCompressor() const;
00111 
00123         virtual bool isDirty() const { return true; }
00124 
00142         CO_API void push( const uint128_t& groupID, const uint128_t& typeID,
00143                           const Nodes& nodes );
00144 
00177         CO_API virtual uint128_t commit( const uint32_t incarnation =
00178                                          CO_COMMIT_NEXT );
00179 
00190         CO_API void setAutoObsolete( const uint32_t count );
00191 
00193         CO_API uint32_t getAutoObsolete() const;
00194 
00225         CO_API virtual uint128_t sync( const uint128_t& version = VERSION_HEAD);
00226 
00228         CO_API uint128_t getHeadVersion() const;
00229 
00231         CO_API uint128_t getVersion() const;
00232 
00246         CO_API virtual void notifyNewHeadVersion( const uint128_t& version );
00247 
00252         virtual void notifyNewVersion() {}
00254 
00262         virtual void getInstanceData( DataOStream& os ) = 0;
00263 
00272         virtual void applyInstanceData( DataIStream& is ) = 0;
00273 
00282         virtual void pack( DataOStream& os ) { getInstanceData( os ); }
00283 
00289         virtual void unpack( DataIStream& is ) { applyInstanceData( is ); }
00291 
00295         CO_API bool send( NodePtr node, ObjectPacket& packet );
00296 
00298         CO_API bool send( NodePtr node, ObjectPacket& packet,
00299                           const std::string& string );
00300 
00302         CO_API bool send( NodePtr node, ObjectPacket& packet, 
00303                           const void* data, const uint64_t size );
00305 
00313         virtual void notifyAttach() {}
00314 
00322         virtual void notifyAttached() {}
00323 
00331         CO_API virtual void notifyDetach();
00332 
00339         virtual void notifyDetached() {}
00341 
00345         uint32_t getMasterInstanceID() const;
00346 
00348         NodePtr getMasterNode();
00349 
00351         void addSlave( Command& command );
00352         CO_API void removeSlave( NodePtr node ); 
00353         CO_API void removeSlaves( NodePtr node ); 
00354         void setMasterNode( NodePtr node ); 
00355 
00356         void addInstanceDatas( const ObjectDataIStreamDeque&, const uint128_t&);
00357 
00368         void setupChangeManager( const Object::ChangeType type, 
00369                                  const bool master, LocalNodePtr localNode,
00370                                  const uint32_t masterInstanceID );
00375         CO_API virtual void attach( const base::UUID& id, 
00376                                     const uint32_t instanceID );
00382         CO_API virtual void detach();
00383 
00385         void transfer( Object* from );
00386 
00387         void applyMapData( const uint128_t& version ); 
00388         void sendInstanceData( Nodes& nodes ); 
00389 
00390 
00391     protected:
00393         CO_API Object( const Object& );
00394 
00396         const Object& operator = ( const Object& ) { return *this; }
00397 
00398     private:
00399         friend class DeltaMasterCM;
00400         friend class FullMasterCM;
00401         friend class MasterCM;
00402         friend class ObjectCM;
00403         friend class StaticMasterCM;
00404         friend class StaticSlaveCM;
00405         friend class UnbufferedMasterCM;
00406         friend class VersionedSlaveCM;
00407 
00409         base::UUID _id;
00410 
00412         LocalNodePtr _localNode;
00413 
00415         uint32_t _instanceID;
00416 
00418         ObjectCM* _cm;
00419 
00420         void _setChangeManager( ObjectCM* cm );
00421 
00422         EQ_TS_VAR( _thread );
00423     };
00424     CO_API std::ostream& operator << ( std::ostream&, const Object& );
00425 }
00426 
00427 #endif // CO_OBJECT_H
Generated on Fri Jun 8 2012 15:44:31 for Equalizer 1.2.1 by  doxygen 1.8.0