312 GZ_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING
314 GZ_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING
318 template <
class T,
class U>
338 public:
virtual unsigned int Size()
const;
340 public:
virtual bool Contains(
ConstTPtr _object)
const;
342 public:
virtual bool ContainsId(
unsigned int _id)
const;
344 public:
virtual bool ContainsName(
const std::string &_name)
const;
346 public:
virtual TPtr GetById(
unsigned int _id)
const;
350 public:
virtual TPtr GetByIndex(
unsigned int _index)
const;
352 public:
virtual bool Add(
TPtr _object);
354 public:
virtual TPtr Remove(
TPtr _object);
356 public:
virtual TPtr RemoveById(
unsigned int _id);
360 public:
virtual TPtr RemoveByIndex(
unsigned int _index);
362 public:
virtual void RemoveAll();
364 public:
virtual void Destroy(
TPtr _object);
366 public:
virtual void DestroyById(
unsigned int _id);
368 public:
virtual void DestroyByName(
const std::string &_name);
370 public:
virtual void DestroyByIndex(
unsigned int _index);
372 public:
virtual void DestroyAll();
432 template <
class T,
class U>
438 template <
class T,
class U>
444 template <
class T,
class U>
447 return this->map.size();
451 template <
class T,
class U>
454 return this->map.count(_key) > 0;
458 template <
class T,
class U>
461 for (
auto pair : this->map)
463 if (pair.second == _value)
return true;
470 template <
class T,
class U>
474 return this->Derived(_key);
478 template <
class T,
class U>
482 return this->DerivedByIndex(_index);
486 template <
class T,
class U>
501 if (this->ContainsKey(_key))
503 gzerr <<
"Item already registered with key: " << _key <<
std::endl;
511 gzerr <<
"Cannot add item created by another render-engine"
517 this->map[_key] = derived;
522 template <
class T,
class U>
525 auto iter = this->map.find(_key);
527 if (this->IsValidIter(iter))
529 this->map.erase(iter);
534 template <
class T,
class U>
537 auto iter = this->map.begin();
539 while (this->IsValidIter(iter))
541 if (iter->second == _value)
543 this->map.erase(iter);
552 template <
class T,
class U>
559 template <
class T,
class U>
563 auto iter = this->map.find(_key);
564 return (this->IsValidIter(iter)) ? iter->second :
nullptr;
568 template <
class T,
class U>
572 if (_index >= this->Size())
578 auto iter = this->map.begin();
584 template <
class T,
class U>
587 return _iter != this->map.end();
591 template <
class T,
class U>
597 template <
class T,
class U>
603 template <
class T,
class U>
606 return this->store.size();
610 template <
class T,
class U>
611 typename BaseStore<T, U>::UIter
614 return this->store.begin();
618 template <
class T,
class U>
619 typename BaseStore<T, U>::UIter
622 return this->store.end();
626 template <
class T,
class U>
629 auto iter = this->ConstIter(_object);
630 return this->IsValidIter(iter);
634 template <
class T,
class U>
637 auto iter = this->ConstIterById(_id);
638 return this->IsValidIter(iter);
642 template <
class T,
class U>
645 auto iter = this->ConstIterByName(_name);
646 return this->IsValidIter(iter);
650 template <
class T,
class U>
654 return this->DerivedById(_id);
658 template <
class T,
class U>
662 return this->DerivedByName(_name);
666 template <
class T,
class U>
670 return this->DerivedByIndex(_index);
674 template <
class T,
class U>
687 gzerr <<
"Cannot add item created by another render-engine"
693 return this->AddImpl(derived);
697 template <
class T,
class U>
701 auto iter = this->Iter(_object);
702 return this->RemoveImpl(iter);
706 template <
class T,
class U>
710 return this->RemoveDerivedById(_id);
714 template <
class T,
class U>
718 return this->RemoveDerivedByName(_name);
722 template <
class T,
class U>
726 return this->RemoveDerivedByIndex(_index);
730 template <
class T,
class U>
734 this->storeMap.clear();
738 template <
class T,
class U>
741 auto iter = this->Iter(_object);
742 this->DestroyImpl(iter);
746 template <
class T,
class U>
749 auto iter = this->IterById(_id);
750 this->DestroyImpl(iter);
754 template <
class T,
class U>
757 auto iter = this->IterByName(_name);
758 this->DestroyImpl(iter);
762 template <
class T,
class U>
765 auto iter = this->IterByIndex(_index);
766 this->DestroyImpl(iter);
770 template <
class T,
class U>
773 unsigned int i = this->Size();
777 this->DestroyByIndex(--i);
782 template <
class T,
class U>
786 auto iter = this->ConstIterById(_id);
787 return (this->IsValidIter(iter)) ? *iter :
nullptr;
791 template <
class T,
class U>
795 auto iter = this->ConstIterByName(_name);
796 return (this->IsValidIter(iter)) ? *iter :
nullptr;
800 template <
class T,
class U>
804 auto iter = this->ConstIterByIndex(_index);
805 return (this->IsValidIter(iter)) ? *iter :
nullptr;
809 template <
class T,
class U>
818 return this->AddImpl(_object);
822 template <
class T,
class U>
826 auto iter = this->Iter(_object);
827 return this->RemoveImpl(iter);
831 template <
class T,
class U>
835 auto iter = this->IterById(_id);
836 return this->RemoveImpl(iter);
840 template <
class T,
class U>
844 auto iter = this->IterByName(_name);
845 return this->RemoveImpl(iter);
849 template <
class T,
class U>
853 auto iter = this->IterByIndex(_index);
854 return this->RemoveImpl(iter);
858 template <
class T,
class U>
859 typename BaseStore<T, U>::ConstUIter
862 auto begin = this->store.begin();
863 auto end = this->store.end();
865 for (
auto iter = begin; iter != end; ++iter)
867 if (*iter == _object)
877 template <
class T,
class U>
878 typename BaseStore<T, U>::ConstUIter
881 auto begin = this->store.begin();
882 auto end = this->store.end();
884 for (
auto iter = begin; iter != end; ++iter)
886 if ((*iter)->Id() == _id)
896 template <
class T,
class U>
897 typename BaseStore<T, U>::ConstUIter
900 auto idx = this->storeMap.find(_name);
901 if (idx == this->storeMap.end())
903 return this->store.end();
905 return ConstIterByIndex(idx->second);
909 template <
class T,
class U>
910 typename BaseStore<T, U>::ConstUIter
913 if (_index >= this->Size())
916 return this->store.end();
919 auto iter = this->store.begin();
925 template <
class T,
class U>
926 typename BaseStore<T, U>::UIter
929 auto iter = this->ConstIter(_object);
930 return this->RemoveConstness(iter);
934 template <
class T,
class U>
935 typename BaseStore<T, U>::UIter
938 auto iter = this->ConstIterById(_id);
939 return this->RemoveConstness(iter);
943 template <
class T,
class U>
944 typename BaseStore<T, U>::UIter
947 auto iter = this->ConstIterByName(_name);
948 return this->RemoveConstness(iter);
952 template <
class T,
class U>
953 typename BaseStore<T, U>::UIter
956 auto iter = this->ConstIterByIndex(_index);
957 return this->RemoveConstness(iter);
961 template <
class T,
class U>
964 unsigned int id = _object->Id();
967 if (this->ContainsId(
id))
969 gzerr <<
"Another item already exists with id: " <<
id <<
std::endl;
973 if (this->ContainsName(name))
975 gzerr <<
"Another item already exists with name: " << name
980 this->storeMap[name] = this->store.
size();
981 this->store.emplace_back(_object);
986 template <
class T,
class U>
990 if (!this->IsValidIter(_iter))
998 for (
auto &[name, objIdx] : this->storeMap)
1006 this->storeMap.
erase(nameToErase);
1008 UPtr result = *_iter;
1009 this->store.erase(_iter);
1014 template <
class T,
class U>
1017 UPtr result = this->RemoveImpl(_iter);
1018 if (result) result->Destroy();
1022 template <
class T,
class U>
1025 return _iter != this->store.end();
1029 template <
class T,
class U>
1030 typename BaseStore<T, U>::UIter
1033 return (this->IsValidIter(_iter)) ?
1034 this->store.erase(_iter, _iter) : this->store.end();
1053 unsigned int size = 0;
1055 for (
auto store : this->stores)
1057 size += store->Size();
1067 for (
auto store : this->stores)
1069 if (store->Contains(_object))
return true;
1079 for (
auto store : this->stores)
1081 if (store->ContainsId(_id))
return true;
1091 for (
auto store : this->stores)
1093 if (store->ContainsName(_name))
return true;
1104 for (
auto store : this->stores)
1106 TPtr object = store->GetById(_id);
1107 if (
object)
return object;
1118 for (
auto store : this->stores)
1120 TPtr object = store->GetByName(_name);
1121 if (
object)
return object;
1132 unsigned int origIndex = _index;
1134 for (
auto store : this->stores)
1136 unsigned int size = store->Size();
1138 return store->GetByIndex(_index);
1150 gzerr <<
"Adding to BaseCompositeStore not supported" <<
std::endl;
1159 TPtr result =
nullptr;
1161 for (
auto store : this->stores)
1163 TPtr temp = store->Remove(_object);
1164 if (!result) result = temp;
1175 TPtr result =
nullptr;
1177 for (
auto store : this->stores)
1179 TPtr temp = store->RemoveById(_id);
1180 if (!result) result = temp;
1191 TPtr result =
nullptr;
1193 for (
auto store : this->stores)
1195 TPtr temp = store->RemoveByName(_name);
1196 if (!result) result = temp;
1207 TPtr result =
nullptr;
1209 for (
auto store : this->stores)
1211 TPtr temp = store->RemoveByIndex(_index);
1212 if (!result) result = temp;
1222 for (
auto store : this->stores)
1232 for (
auto store : this->stores)
1234 if (store->Contains(_object))
1236 store->Destroy(_object);
1246 for (
auto store : this->stores)
1248 store->DestroyById(_id);
1256 for (
auto store : this->stores)
1258 store->DestroyByName(_name);
1266 for (
auto store : this->stores)
1268 store->DestroyByIndex(_index);
1276 for (
auto store : this->stores)
1278 store->DestroyAll();
1286 return this->stores.size();
1293 auto begin = this->stores.begin();
1294 auto end = this->stores.end();
1295 auto iter =
std::find(begin, end, _store);
1304 if (_index >= this->GetStoreCount())
1310 return this->stores[_index];
1323 if (this->ContainsStore(_store))
1329 this->stores.push_back(_store);
1338 auto begin = this->stores.begin();
1339 auto end = this->stores.end();
1340 auto iter =
std::find(begin, end, _store);
1341 return this->RemoveStoreImpl(iter);
1349 if (_index >= this->GetStoreCount())
1355 auto iter = this->stores.begin();
1357 return this->RemoveStoreImpl(iter);
1365 if (_iter == this->stores.end())
1371 this->stores.erase(_iter);