#pragma once #include #include #include #include "ray/core.h" namespace ray { namespace api { /// Represents an object in the object store.. /// \param T The type of object. template class ObjectRef { public: ObjectRef(); ObjectRef(const ObjectID &id); bool operator==(const ObjectRef &object) const; /// Get a untyped ID of the object const ObjectID &ID() const; /// Get the object from the object store. /// This method will be blocked until the object is ready. /// /// \return shared pointer of the result. std::shared_ptr Get() const; /// Make ObjectRef serializable MSGPACK_DEFINE(id_); private: ObjectID id_; }; // ---------- implementation ---------- #include template ObjectRef::ObjectRef() {} template ObjectRef::ObjectRef(const ObjectID &id) { id_ = id; } template inline bool ObjectRef::operator==(const ObjectRef &object) const { return id_ == object.id_; } template const ObjectID &ObjectRef::ID() const { return id_; } template inline std::shared_ptr ObjectRef::Get() const { return Ray::Get(*this); } } // namespace api } // namespace ray