62 template<
typename T,
typename F>
65 auto& idx = get_mutable_index<T>();
66 return static_cast<const T&
>( idx.create( [&](
object& o)
68 assert(
dynamic_cast<T*
>(&o) );
69 constructor(
static_cast<T&
>(o) );
76 template<
typename IndexType>
78 static_assert( std::is_base_of<index,IndexType>::value,
"Type must be an index type" );
79 return static_cast<const IndexType&
>(
get_index( IndexType::object_type::space_id,
80 IndexType::object_type::type_id ) );
98 template<
typename T,
typename Lambda>
99 void modify(
const T& obj,
const Lambda& m ) {
106 static const T&
cast(
const object& obj )
108 assert(
nullptr !=
dynamic_cast<const T*
>(&obj) );
109 return static_cast<const T&
>(obj);
114 assert(
nullptr !=
dynamic_cast<T*
>(&obj) );
115 return static_cast<T&
>(obj);
122 assert(
nullptr !=
dynamic_cast<const T*
>(&obj) );
123 return static_cast<const T&
>(obj);
129 assert( !obj ||
nullptr !=
dynamic_cast<const T*
>(obj) );
130 return static_cast<const T*
>(obj);
133 template<u
int8_t SpaceID, u
int8_t TypeID>
138 template<u
int8_t SpaceID, u
int8_t TypeID>
143 template<
typename IndexType>
146 using ObjectType =
typename IndexType::object_type;
147 const auto space_id = ObjectType::space_id;
148 const auto type_id = ObjectType::type_id;
149 FC_ASSERT( space_id < _index.size(),
"Space ID ${s} overflow", (
"s",space_id) );
150 if( _index[space_id].size() <= type_id )
152 FC_ASSERT( type_id < _index[space_id].size(),
"Type ID ${t} overflow", (
"t",type_id) );
153 FC_ASSERT( !_index[space_id][type_id],
"Index ${s}.${t} already exists", (
"s",space_id)(
"t",type_id) );
154 _index[space_id][type_id] = std::make_unique<IndexType>(*
this);
155 return static_cast<IndexType*
>(_index[space_id][type_id].get());
158 template<
typename IndexType,
typename SecondaryIndexType,
typename... Args>
161 return get_mutable_index_type<IndexType>().template
172 template<
typename IndexType>
174 static_assert( std::is_base_of<index,IndexType>::value,
"Type must be an index type" );
175 return static_cast<IndexType&
>(
get_mutable_index( IndexType::object_type::space_id,
176 IndexType::object_type::type_id ) );
187 void save_undo(
const object& obj );
188 void save_undo_add(
const object& obj );
189 void save_undo_remove(
const object& obj );
192 std::vector< std::vector< std::unique_ptr<index> > > _index;