40 void reset( uint8_t s, uint8_t t, uint64_t i )
42 FC_ASSERT( i >> instance_bits == 0,
"instance overflow", (
"instance",i) );
51 explicit operator uint64_t()
const {
return number; }
65 template<
typename T >
72 template<
typename T >
78 explicit operator std::string()
const 90 template<
typename ObjectID>
93 #define MAP_OBJECT_ID_TO_TYPE(OBJECT) \ 94 namespace graphene { namespace db { \ 96 struct object_downcast<const graphene::db::object_id<OBJECT::space_id, \ 97 OBJECT::type_id>&> { using type = OBJECT; }; \ 99 template<
typename ObjectID>
102 template<u
int8_t SpaceID, u
int8_t TypeID>
105 static constexpr uint8_t type_bits = 8;
109 static constexpr uint8_t space_id = SpaceID;
110 static constexpr uint8_t type_id = TypeID;
112 static constexpr uint16_t
space_type = uint16_t(uint16_t(space_id) << type_bits) | uint16_t(type_id);
131 FC_ASSERT(
id.
is<std::remove_reference_t<decltype(*
this)>>(),
"space or type mismatch" );
151 template<
typename DB>
152 auto operator()(
const DB& db)
const ->
const decltype(db.get(*
this))& {
return db.get(*
this); }
172 explicit operator std::string()
const 186 template<u
int8_t SpaceID, u
int8_t TypeID>
191 static std::string _str = string(
"graphene::db::object_id<") +
fc::to_string(SpaceID) +
":" 197 template<u
int8_t SpaceID, u
int8_t TypeID>
207 local_member_count = 1,
208 total_member_count = 1
210 template<
typename Visitor>
211 static inline void visit(
const Visitor& visitor )
213 using member_type = decltype(((
type*)
nullptr)->
instance);
214 visitor.TEMPLATE operator()<member_type,
type,&type::instance>(
"instance" );
217 namespace member_names {
218 template<u
int8_t S, u
int8_t T>
225 vo = std::string( var );
231 auto first_dot = s.find(
'.');
232 FC_ASSERT( first_dot != std::string::npos,
"Missing the first dot" );
233 FC_ASSERT( first_dot != 0,
"Missing the space part" );
234 auto second_dot = s.find(
'.',first_dot+1);
235 FC_ASSERT( second_dot != std::string::npos,
"Missing the second dot" );
236 FC_ASSERT( second_dot != first_dot+1,
"Missing the type part" );
239 auto type_id =
fc::to_uint64( s.substr( first_dot+1, (second_dot-first_dot)-1 ) );
242 vo.
reset( static_cast<uint8_t>(space_id), static_cast<uint8_t>(type_id),
instance );
244 template<u
int8_t SpaceID, u
int8_t TypeID>
247 vo = std::string( var );
249 template<u
int8_t SpaceID, u
int8_t TypeID>
253 auto first_dot = s.find(
'.');
254 FC_ASSERT( first_dot != std::string::npos,
"Missing the first dot" );
255 FC_ASSERT( first_dot != 0,
"Missing the space part" );
256 auto second_dot = s.find(
'.',first_dot+1);
257 FC_ASSERT( second_dot != std::string::npos,
"Missing the second dot" );
258 FC_ASSERT( second_dot != first_dot+1,
"Missing the type part" );
260 fc::to_uint64( s.substr( first_dot+1, (second_dot-first_dot)-1 ) ) == TypeID,
261 "Space.Type.0 (${SpaceID}.${TypeID}.0) doesn't match expected value ${var}",
262 (
"TypeID",TypeID)(
"SpaceID",SpaceID)(
"var",var) );
270 template <>
struct hash<
graphene::db::object_id_type>
274 return std::hash<uint64_t>()(x.
number);
friend object_id operator+(const object_id &a, int64_t delta)
object_id & operator=(const object_id_type &o)
object_id(const object_id_type &id)
#define FC_REFLECT(TYPE, MEMBERS)
Specializes fc::reflector for TYPE.
auto operator()(const DB &db) const -> const decltype(db.get(*this))&
friend bool operator>(const object_id_type &a, const object_id_type &b)
friend object_id_type operator+(const object_id_type &a, int64_t delta)
fc::unsigned_int instance
uint64_t instance() const
void reset(uint8_t s, uint8_t t, uint64_t i)
friend bool operator==(const object_id_type &a, const object_id_type &b)
static constexpr uint64_t max_instance
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...
object_id(const fc::unsigned_int &i)
maintains a set of indexed objects that can be modified with multi-level rollback support ...
friend size_t hash_value(const object_id &v)
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.
static constexpr uint8_t instance_bits
uint64_t to_uint64(const std::string &)
static const char * name()
static void visit(const Visitor &visitor)
Defines exception's used by fc.
uint16_t space_type() const
typename object_downcast< ObjectID >::type object_downcast_t
std::string to_string(double)
static constexpr uint64_t one_byte_mask
friend bool operator<(const object_id_type &a, const object_id_type &b)
const std::string & get_string() const
friend bool operator!=(const object_id_type &a, const object_id_type &b)
base for all database objects
static constexpr uint8_t type_and_instance_bits
friend size_t hash_value(const object_id_type &v)
size_t operator()(const graphene::db::object_id_type &x) const
static constexpr object_id max()
std::true_type is_defined
object_id_type & operator++()
A template which stores the name of the native member at a given index in a given class...