11 static ObjectId create() {
13 new_id._value = ((uint64_t)((uint16_t)(
Randomizer<uint16_t>().getRandom(0x0000, 0xFFFF))) << 48 ) |
14 (Timer::getTimeEpocUS() & 0x0000FFFFFFFFFFFFULL);
19 : _value( _invalidId ) {}
21 ObjectId(
const ObjectId& other )
22 : _value( other._value ) {}
24 bool isValid()
const {
25 return _value != _invalidId;
28 const ObjectId &operator =(
const ObjectId &b) {
33 operator std::string()
const {
34 return std::to_string( _value );
37 friend void to_json(nlohmann::json& j,
const ObjectId& s) {
41 friend void from_json(
const nlohmann::json& j, ObjectId& s) {
42 s._value = j.get<uint64_t>();
45 friend bool operator == (
const ObjectId &a,
const ObjectId &b) {
46 return a._value == b._value;
49 friend bool operator != (
const ObjectId &a,
const ObjectId &b) {
50 return a._value != b._value;
53 friend bool operator < (
const ObjectId &a,
const ObjectId &b) {
54 return a._value < b._value;
58 static constexpr uint64_t _invalidId = 0;