19 #ifndef EQFABRIC_OBJECT_H 20 #define EQFABRIC_OBJECT_H 22 #include <co/objectOCommand.h> 23 #include <co/objectVersion.h> 24 #include <co/serializable.h> 26 #include <eq/fabric/error.h> 27 #include <eq/fabric/types.h> 44 class Object :
public co::Serializable
50 EQFABRIC_API
virtual void setName(
const std::string& name);
53 EQFABRIC_API
const std::string& getName()
const;
64 EQFABRIC_API
void setUserData(co::Object* userData);
67 EQFABRIC_API co::Object* getUserData();
70 EQFABRIC_API
const co::Object* getUserData()
const;
84 EQFABRIC_API uint32_t getTasks()
const;
86 EQFABRIC_API uint32_t getSerial()
const;
90 EQFABRIC_API
bool isDirty()
const override;
93 EQFABRIC_API uint128_t
94 commit(
const uint32_t incarnation = CO_COMMIT_NEXT)
override;
97 EQFABRIC_API
virtual void backup();
100 EQFABRIC_API
virtual void restore();
109 DIRTY_NAME = Serializable::DIRTY_CUSTOM << 0,
110 DIRTY_USERDATA = Serializable::DIRTY_CUSTOM << 1,
111 DIRTY_TASKS = Serializable::DIRTY_CUSTOM << 2,
112 DIRTY_REMOVED = Serializable::DIRTY_CUSTOM << 3,
113 DIRTY_SERIAL = Serializable::DIRTY_CUSTOM << 4,
115 DIRTY_CUSTOM = Serializable::DIRTY_CUSTOM << 6,
116 DIRTY_OBJECT_BITS = DIRTY_NAME | DIRTY_USERDATA
124 EQFABRIC_API Object(
const Object&);
127 EQFABRIC_API
virtual ~Object();
130 EQFABRIC_API Object& operator=(
const Object& from);
140 EQFABRIC_API
void setTasks(
const uint32_t tasks);
142 EQFABRIC_API
void notifyDetach()
override;
144 EQFABRIC_API
void serialize(co::DataOStream& os,
145 const uint64_t dirtyBits)
override;
146 EQFABRIC_API
void deserialize(co::DataIStream& is,
147 const uint64_t dirtyBits)
override;
150 virtual uint64_t getRedistributableBits()
const 152 return DIRTY_OBJECT_BITS;
160 EQFABRIC_API
void postRemove(Object* child);
163 virtual void removeChild(
const uint128_t&) { LBUNIMPLEMENTED; }
165 template <
class C,
class S>
166 void commitChild(C* child, S* sender, uint32_t cmd,
167 const uint32_t incarnation);
171 inline void commitChild(C* child,
const uint32_t incarnation)
173 LBASSERT(child->isAttached());
174 child->commit(incarnation);
178 template <
class C,
class S>
179 void commitChildren(
const std::vector<C*>& children, S* sender,
180 uint32_t cmd,
const uint32_t incarnation);
184 void commitChildren(
const std::vector<C*>& children, uint32_t cmd,
185 const uint32_t incarnation)
187 commitChildren<C, Object>(children,
this, cmd, incarnation);
192 void commitChildren(
const std::vector<C*>& children,
193 const uint32_t incarnation);
197 void syncChildren(
const std::vector<C*>& children);
200 template <
class P,
class C>
201 inline void releaseChildren(
const std::vector<C*>& children);
204 EQFABRIC_API
bool _cmdSync(co::ICommand& command);
206 EQFABRIC_API
void updateEvent(
Event& event, int64_t time);
209 detail::Object*
const _impl;
213 template <
class C,
class S>
214 inline void Object::commitChild(C* child, S* sender, uint32_t cmd,
215 const uint32_t incarnation)
217 if (!child->isAttached())
219 LBASSERT(!isMaster());
220 co::LocalNodePtr localNode = child->getConfig()->getLocalNode();
221 lunchbox::Request<uint128_t> request =
222 localNode->registerRequest<uint128_t>();
223 co::NodePtr node = child->getServer().get();
224 sender->send(node, cmd) << request;
226 LBCHECK(localNode->mapObject(child, request.wait(), co::VERSION_NONE));
228 child->commit(incarnation);
231 template <
class C,
class S>
232 inline void Object::commitChildren(
const std::vector<C*>& children, S* sender,
233 uint32_t cmd,
const uint32_t incarnation)
236 for (
typename std::vector<C*>::const_iterator i = children.begin();
237 i != children.end(); ++i)
240 commitChild<C, S>(child, sender, cmd, incarnation);
245 inline void Object::commitChildren(
const std::vector<C*>& children,
246 const uint32_t incarnation)
249 for (
typename std::vector<C*>::const_iterator i = children.begin();
250 i != children.end(); ++i)
253 LBASSERT(child->isAttached());
254 child->commit(incarnation);
259 inline void Object::syncChildren(
const std::vector<C*>& children)
261 for (
typename std::vector<C*>::const_iterator i = children.begin();
262 i != children.end(); ++i)
265 LBASSERT(child->isMaster());
270 template <
class P,
class C>
271 inline void Object::releaseChildren(
const std::vector<C*>& children)
273 for (
size_t i = children.size(); i > 0; --i)
275 C* child = children[i - 1];
277 if (child->isAttached())
279 getLocalNode()->releaseObject(child);
282 static_cast<P*
>(
this)->_removeChild(child);
283 static_cast<P*
>(
this)->release(child);
288 LBASSERT(isMaster());
294 #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()