19 #ifndef EQFABRIC_OBJECT_H
20 #define EQFABRIC_OBJECT_H
22 #include <eq/fabric/api.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>
39 class Object :
public co::Serializable
45 EQFABRIC_API
void setName(
const std::string& name );
48 EQFABRIC_API
const std::string&
getName()
const;
59 EQFABRIC_API
void setUserData( co::Object* userData );
79 EQFABRIC_API
void setError(
const int32_t error );
98 uint32_t getSerial()
const {
return _serial; }
102 EQFABRIC_API
virtual bool isDirty()
const;
105 EQFABRIC_API
virtual uint128_t commit(
const uint32_t incarnation =
109 EQFABRIC_API
virtual void backup();
112 EQFABRIC_API
virtual void restore();
121 DIRTY_NAME = Serializable::DIRTY_CUSTOM << 0,
122 DIRTY_USERDATA = Serializable::DIRTY_CUSTOM << 1,
123 DIRTY_ERROR = Serializable::DIRTY_CUSTOM << 2,
124 DIRTY_TASKS = Serializable::DIRTY_CUSTOM << 3,
125 DIRTY_REMOVED = Serializable::DIRTY_CUSTOM << 4,
126 DIRTY_SERIAL = Serializable::DIRTY_CUSTOM << 5,
128 DIRTY_CUSTOM = Serializable::DIRTY_CUSTOM << 6,
129 DIRTY_OBJECT_BITS = DIRTY_NAME | DIRTY_USERDATA | DIRTY_ERROR
137 EQFABRIC_API
virtual ~Object();
149 EQFABRIC_API
void setTasks(
const uint32_t tasks );
151 EQFABRIC_API
virtual void notifyDetach();
153 EQFABRIC_API
virtual void serialize( co::DataOStream& os,
154 const uint64_t dirtyBits );
155 EQFABRIC_API
virtual void deserialize( co::DataIStream& is,
156 const uint64_t dirtyBits );
159 virtual uint64_t getRedistributableBits()
const
160 {
return DIRTY_OBJECT_BITS; }
167 EQFABRIC_API
void postRemove(
Object* child );
170 virtual void removeChild(
const UUID& ) { LBUNIMPLEMENTED; }
173 template<
class C,
class S >
174 void commitChild( C* child, S* sender, uint32_t cmd,
175 const uint32_t incarnation );
178 template<
class C >
inline
179 void commitChild( C* child,
const uint32_t incarnation )
181 LBASSERT( child->isAttached( ));
182 child->commit( incarnation );
186 template<
class C,
class S >
187 void commitChildren(
const std::vector< C* >& children, S* sender,
188 uint32_t cmd,
const uint32_t incarnation );
192 void commitChildren(
const std::vector< C* >& children, uint32_t cmd,
193 const uint32_t incarnation )
194 { commitChildren< C, Object >( children,
this, cmd, incarnation ); }
198 void commitChildren(
const std::vector< C* >& children,
199 const uint32_t incarnation );
203 void syncChildren(
const std::vector< C* >& children );
206 template<
class P,
class C >
207 inline void releaseChildren(
const std::vector< C* >& children );
210 EQFABRIC_API
bool _cmdSync( co::ICommand& command );
219 co::ObjectVersion userData;
224 co::Object* _userData;
236 std::vector< UUID > _removedChildren;
243 template<
class C,
class S >
inline void
244 Object::commitChild( C* child, S* sender, uint32_t cmd,
245 const uint32_t incarnation )
247 if( !child->isAttached( ))
249 LBASSERT( !isMaster( ));
250 co::LocalNodePtr localNode = child->getConfig()->getLocalNode();
251 const uint32_t requestID = localNode->registerRequest();
253 co::NodePtr node = child->getServer().get();
254 sender->send( node, cmd ) << requestID;
256 uint128_t identifier;
257 localNode->waitRequest( requestID, identifier );
258 LBCHECK( localNode->mapObject( child,identifier,co::VERSION_NONE ));
260 child->commit( incarnation );
263 template<
class C,
class S >
inline void
264 Object::commitChildren(
const std::vector< C* >& children, S* sender,
265 uint32_t cmd,
const uint32_t incarnation )
268 for(
typename std::vector< C* >::const_iterator i = children.begin();
269 i != children.end(); ++i )
272 commitChild< C, S >( child, sender, cmd, incarnation );
277 inline void Object::commitChildren(
const std::vector< C* >& children,
278 const uint32_t incarnation )
281 for(
typename std::vector< C* >::const_iterator i = children.begin();
282 i != children.end(); ++i )
285 LBASSERT( child->isAttached( ));
286 child->commit( incarnation );
291 inline void Object::syncChildren(
const std::vector< C* >& children )
293 for(
typename std::vector< C* >::const_iterator i = children.begin();
294 i != children.end(); ++i )
297 LBASSERT( child->isMaster( ));
302 template<
class P,
class C >
303 inline void Object::releaseChildren(
const std::vector< C* >& children )
305 for(
size_t i = children.size(); i > 0; --i )
307 C* child = children[ i - 1 ];
309 if( child->isAttached( ))
311 getLocalNode()->releaseObject( child );
314 static_cast< P*
>( this )->_removeChild( child );
315 static_cast< P*
>( this )->release( child );
320 LBASSERT( isMaster( ));
326 #endif // EQFABRIC_OBJECT_H
Internal base class for all distributed, inheritable Equalizer objects.
uint32_t getTasks() const
Return the set of tasks this channel might execute in the worst case.
eq::fabric::Error getError() const
void setName(const std::string &name)
Set the name of the object.
Error
Defines errors produced by Equalizer classes.
virtual uint32_t getUserDataLatency() const
virtual ~Object()
Destruct the object.
virtual bool isDirty() const
virtual bool hasMasterUserData()
const co::Object * getUserData() const
co::Object * getUserData()
DirtyBits
The changed parts of the object since the last pack().
void setError(const int32_t error)
Set an error code why the last operation failed.
const std::string & getName() const
Object()
Construct a new Object.
void setUserData(co::Object *userData)
Set user-specific data.