19 #ifndef EQFABRIC_OBJECT_H 20 #define EQFABRIC_OBJECT_H 23 #include <eq/fabric/error.h> 24 #include <eq/fabric/types.h> 25 #include <co/objectOCommand.h> 26 #include <co/objectVersion.h> 27 #include <co/serializable.h> 33 namespace detail {
class Object; }
41 class Object :
public co::Serializable
47 EQFABRIC_API
virtual void setName(
const std::string& name );
50 EQFABRIC_API
const std::string& getName()
const;
61 EQFABRIC_API
void setUserData( co::Object* userData );
64 EQFABRIC_API co::Object* getUserData();
67 EQFABRIC_API
const co::Object* getUserData()
const;
81 EQFABRIC_API uint32_t getTasks()
const;
83 EQFABRIC_API uint32_t getSerial()
const;
87 EQFABRIC_API
bool isDirty()
const override;
90 EQFABRIC_API uint128_t commit(
const uint32_t incarnation =
91 CO_COMMIT_NEXT )
override;
94 EQFABRIC_API
virtual void backup();
97 EQFABRIC_API
virtual void restore();
106 DIRTY_NAME = Serializable::DIRTY_CUSTOM << 0,
107 DIRTY_USERDATA = Serializable::DIRTY_CUSTOM << 1,
108 DIRTY_TASKS = Serializable::DIRTY_CUSTOM << 2,
109 DIRTY_REMOVED = Serializable::DIRTY_CUSTOM << 3,
110 DIRTY_SERIAL = Serializable::DIRTY_CUSTOM << 4,
112 DIRTY_CUSTOM = Serializable::DIRTY_CUSTOM << 6,
113 DIRTY_OBJECT_BITS = DIRTY_NAME | DIRTY_USERDATA
121 EQFABRIC_API Object(
const Object& );
124 EQFABRIC_API
virtual ~Object();
127 EQFABRIC_API Object& operator = (
const Object& from );
139 EQFABRIC_API
void setTasks(
const uint32_t tasks );
141 EQFABRIC_API
void notifyDetach()
override;
143 EQFABRIC_API
void serialize( co::DataOStream& os,
144 const uint64_t dirtyBits )
override;
145 EQFABRIC_API
void deserialize( co::DataIStream& is,
146 const uint64_t dirtyBits )
override;
149 virtual uint64_t getRedistributableBits()
const 150 {
return DIRTY_OBJECT_BITS; }
157 EQFABRIC_API
void postRemove( Object* child );
160 virtual void removeChild(
const uint128_t& ) { LBUNIMPLEMENTED; }
163 template<
class C,
class S >
164 void commitChild( C* child, S* sender, uint32_t cmd,
165 const uint32_t incarnation );
168 template<
class C >
inline 169 void commitChild( C* child,
const uint32_t incarnation )
171 LBASSERT( child->isAttached( ));
172 child->commit( incarnation );
176 template<
class C,
class S >
177 void commitChildren(
const std::vector< C* >& children, S* sender,
178 uint32_t cmd,
const uint32_t incarnation );
182 void commitChildren(
const std::vector< C* >& children, uint32_t cmd,
183 const uint32_t incarnation )
184 { commitChildren< C, Object >( children,
this, cmd, incarnation ); }
188 void commitChildren(
const std::vector< C* >& children,
189 const uint32_t incarnation );
193 void syncChildren(
const std::vector< C* >& children );
196 template<
class P,
class C >
197 inline void releaseChildren(
const std::vector< C* >& children );
200 EQFABRIC_API
bool _cmdSync( co::ICommand& command );
202 EQFABRIC_API
void updateEvent(
Event& event, int64_t time );
205 detail::Object*
const _impl;
209 template<
class C,
class S >
inline void 210 Object::commitChild( C* child, S* sender, uint32_t cmd,
211 const uint32_t incarnation )
213 if( !child->isAttached( ))
215 LBASSERT( !isMaster( ));
216 co::LocalNodePtr localNode = child->getConfig()->getLocalNode();
217 lunchbox::Request< uint128_t > request =
218 localNode->registerRequest< uint128_t >();
219 co::NodePtr node = child->getServer().get();
220 sender->send( node, cmd ) << request;
222 LBCHECK( localNode->mapObject( child, request.wait(),
225 child->commit( incarnation );
228 template<
class C,
class S >
inline void 229 Object::commitChildren(
const std::vector< C* >& children, S* sender,
230 uint32_t cmd,
const uint32_t incarnation )
233 for(
typename std::vector< C* >::const_iterator i = children.begin();
234 i != children.end(); ++i )
237 commitChild< C, S >( child, sender, cmd, incarnation );
242 inline void Object::commitChildren(
const std::vector< C* >& children,
243 const uint32_t incarnation )
246 for(
typename std::vector< C* >::const_iterator i = children.begin();
247 i != children.end(); ++i )
250 LBASSERT( child->isAttached( ));
251 child->commit( incarnation );
256 inline void Object::syncChildren(
const std::vector< C* >& children )
258 for(
typename std::vector< C* >::const_iterator i = children.begin();
259 i != children.end(); ++i )
262 LBASSERT( child->isMaster( ));
267 template<
class P,
class C >
268 inline void Object::releaseChildren(
const std::vector< C* >& children )
270 for(
size_t i = children.size(); i > 0; --i )
272 C* child = children[ i - 1 ];
274 if( child->isAttached( ))
276 getLocalNode()->releaseObject( child );
279 static_cast< P*
>( this )->_removeChild( child );
280 static_cast< P*
>( this )->release( child );
285 LBASSERT( isMaster( ));
291 #endif // EQFABRIC_OBJECT_H Base event structure to report window system and other events.
Defines export visibility macros for library EqualizerFabric.
virtual uint32_t getUserDataLatency() const
DirtyBits
The changed parts of the object since the last pack().
The Equalizer client library.
Internal base class for all distributed, inheritable Equalizer objects.
virtual bool hasMasterUserData()