28 #define GRAPHENE_DB_MAX_INSTANCE_ID (uint64_t(-1)>>16) 31 using std::shared_ptr;
32 using std::unique_ptr;
42 FC_ASSERT( i >> 48 == 0,
"instance overflow", (
"instance",i) );
43 number = (uint64_t(s)<<56) | (uint64_t(t)<<48) | i;
52 explicit operator uint64_t()
const {
return number; }
70 template<
typename T >
73 return (
number >> 48) == ((T::space_id << 8) | (T::type_id));
76 template<
typename T >
83 explicit operator std::string()
const 95 template<
typename ObjectID>
98 #define MAP_OBJECT_ID_TO_TYPE(OBJECT) \ 99 namespace graphene { namespace db { \ 101 struct object_downcast<graphene::db::object_id<OBJECT::space_id, \ 102 OBJECT::type_id>> { using type = OBJECT; }; \ 104 template<
typename ObjectID>
107 template<u
int8_t SpaceID, u
int8_t TypeID>
110 static constexpr uint8_t space_id = SpaceID;
111 static constexpr uint8_t type_id = TypeID;
129 template<
typename DB>
130 auto operator()(
const DB& db)
const ->
const decltype(db.get(*
this))& {
return db.get(*
this); }
157 template<u
int8_t SpaceID, u
int8_t TypeID>
167 template<u
int8_t SpaceID, u
int8_t TypeID>
177 local_member_count = 1,
178 total_member_count = 1
180 template<
typename Visitor>
181 static inline void visit(
const Visitor& visitor )
183 typedef decltype(((type*)
nullptr)->
instance) member_type;
184 visitor.TEMPLATE operator()<member_type,
type,&type::instance>(
"instance" );
187 namespace member_names {
188 template<u
int8_t S, u
int8_t T>
195 vo = std::string( var );
202 auto first_dot = s.find(
'.');
203 auto second_dot = s.find(
'.',first_dot+1);
205 FC_ASSERT( first_dot != 0 && first_dot != std::string::npos );
210 auto type_id =
fc::to_uint64( s.substr( first_dot+1, second_dot-first_dot-1 ) );
212 vo.
number |= (space_id << 56) | (type_id << 48);
214 template<u
int8_t SpaceID, u
int8_t TypeID>
219 template<u
int8_t SpaceID, u
int8_t TypeID>
223 auto first_dot = s.find(
'.');
224 auto second_dot = s.find(
'.',first_dot+1);
226 FC_ASSERT( first_dot != 0 && first_dot != std::string::npos );
228 fc::to_uint64( s.substr( first_dot+1, second_dot-first_dot-1 ) ) == TypeID,
229 "Space.Type.0 (${SpaceID}.${TypeID}.0) doesn't match expected value ${var}", (
"TypeID",TypeID)(
"SpaceID",SpaceID)(
"var",var) );
236 template <>
struct hash<
graphene::db::object_id_type>
240 return std::hash<uint64_t>()(x.
number);
const std::string & get_string() const
object_id(unsigned_int i)
#define FC_REFLECT(TYPE, MEMBERS)
Specializes fc::reflector for TYPE.
auto operator()(const DB &db) const -> const decltype(db.get(*this))&
friend object_id operator+(const object_id a, int delta)
friend bool operator>(const object_id_type &a, const object_id_type &b)
size_t operator()(const graphene::db::object_id_type &x) const
friend object_id_type operator+(const object_id_type &a, int64_t delta)
friend size_t hash_value(object_id v)
object_id_type & operator++(int)
#define GRAPHENE_DB_MAX_INSTANCE_ID
friend size_t hash_value(object_id_type v)
uint64_t instance() const
object_id(object_id_type id)
friend bool operator==(const object_id_type &a, const object_id_type &b)
friend object_id operator+(const object_id a, int64_t delta)
void to_variant(const graphene::db::object_id< SpaceID, TypeID > &var, fc::variant &vo, uint32_t max_depth=1)
This template is used to downcast a generic object type to a specific xyz_object type.
defines visit functions for T Unless this is specialized, visit() will not be defined for T...
maintains a set of indexed objects that can be modified with multi-level rollback support ...
object_id_type(uint8_t s, uint8_t t, uint64_t i)
void from_variant(const fc::variant &var, graphene::db::object_id< SpaceID, TypeID > &vo, uint32_t max_depth=1)
#define FC_CAPTURE_AND_RETHROW(...)
#define FC_ASSERT(TEST,...)
Checks a condition and throws an assert_exception if the test is FALSE.
stores null, int64, uint64, double, bool, string, std::vector<variant>, and variant_object's.
uint64_t to_uint64(const std::string &)
static const char * name()
static void visit(const Visitor &visitor)
Defines exception's used by fc.
typename object_downcast< ObjectID >::type object_downcast_t
std::string to_string(double)
graphene::db::object_id< SpaceID, TypeID > type
defines wrappers for boost::asio functions
friend bool operator<(const object_id_type &a, const object_id_type &b)
std::true_type is_defined
friend object_id_type operator+(const object_id_type &a, int delta)
friend bool operator!=(const object_id_type &a, const object_id_type &b)
base for all database objects
uint16_t space_type() const
object_id_type & operator++()
A template which stores the name of the native member at a given index in a given class...