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 );
81 EQFABRIC_API uint32_t
getTasks()
const;
83 EQFABRIC_API uint32_t getSerial()
const;
87 EQFABRIC_API
virtual bool isDirty()
const;
90 EQFABRIC_API
virtual uint128_t commit(
const uint32_t incarnation =
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
124 EQFABRIC_API
virtual ~Object();
139 EQFABRIC_API
void setTasks(
const uint32_t tasks );
141 EQFABRIC_API
virtual void notifyDetach();
143 EQFABRIC_API
virtual void serialize( co::DataOStream& os,
144 const uint64_t dirtyBits );
145 EQFABRIC_API
virtual void deserialize( co::DataIStream& is,
146 const uint64_t dirtyBits );
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 );
203 detail::Object*
const _impl;
207 template<
class C,
class S >
inline void
208 Object::commitChild( C* child, S* sender, uint32_t cmd,
209 const uint32_t incarnation )
211 if( !child->isAttached( ))
213 LBASSERT( !isMaster( ));
214 co::LocalNodePtr localNode = child->getConfig()->getLocalNode();
215 lunchbox::Request< uint128_t > request =
216 localNode->registerRequest< uint128_t >();
217 co::NodePtr node = child->getServer().get();
218 sender->send( node, cmd ) << request;
220 LBCHECK( localNode->mapObject( child, request.wait(),
223 child->commit( incarnation );
226 template<
class C,
class S >
inline void
227 Object::commitChildren(
const std::vector< C* >& children, S* sender,
228 uint32_t cmd,
const uint32_t incarnation )
231 for(
typename std::vector< C* >::const_iterator i = children.begin();
232 i != children.end(); ++i )
235 commitChild< C, S >( child, sender, cmd, incarnation );
240 inline void Object::commitChildren(
const std::vector< C* >& children,
241 const uint32_t incarnation )
244 for(
typename std::vector< C* >::const_iterator i = children.begin();
245 i != children.end(); ++i )
248 LBASSERT( child->isAttached( ));
249 child->commit( incarnation );
254 inline void Object::syncChildren(
const std::vector< C* >& children )
256 for(
typename std::vector< C* >::const_iterator i = children.begin();
257 i != children.end(); ++i )
260 LBASSERT( child->isMaster( ));
265 template<
class P,
class C >
266 inline void Object::releaseChildren(
const std::vector< C* >& children )
268 for(
size_t i = children.size(); i > 0; --i )
270 C* child = children[ i - 1 ];
272 if( child->isAttached( ))
274 getLocalNode()->releaseObject( child );
277 static_cast< P*
>( this )->_removeChild( child );
278 static_cast< P*
>( this )->release( child );
283 LBASSERT( isMaster( ));
289 #endif // EQFABRIC_OBJECT_H
Defines export visibility macros for library EqualizerFabric.
EQFABRIC_API Object & operator=(const Object &from)
NOP assignment operator.
virtual uint32_t getUserDataLatency() const
DirtyBits
The changed parts of the object since the last pack().
EQFABRIC_API void setUserData(co::Object *userData)
Set user-specific data.
EQFABRIC_API const std::string & getName() const
virtual EQFABRIC_API ~Object()
Destruct the object.
virtual EQFABRIC_API void setName(const std::string &name)
Set the name of the object.
EQFABRIC_API uint32_t getTasks() const
Return the set of tasks this channel might execute in the worst case.
The Equalizer client library.
EQFABRIC_API co::Object * getUserData()
virtual EQFABRIC_API bool isDirty() const
Internal base class for all distributed, inheritable Equalizer objects.
EQFABRIC_API Object()
Construct a new Object.
virtual bool hasMasterUserData()