| 1308 | /// Please note that this is thread-unsafe and should also implement thread-safety mechanisms in implementation. |
| 1309 | template <typename T_Ptr, typename Container> |
| 1310 | class AbstractRegistry : public base::threading::ThreadSafe { |
| 1311 | public: |
| 1312 | typedef typename Container::iterator iterator; |
| 1313 | typedef typename Container::const_iterator const_iterator; |
| 1314 | |
| 1315 | /// @brief Default constructor |
| 1316 | AbstractRegistry(void) {} |
| 1317 | |
| 1318 | /// @brief Move constructor that is useful for base classes |
| 1319 | AbstractRegistry(AbstractRegistry&& sr) { |
| 1320 | if (this == &sr) { |
| 1321 | return; |
| 1322 | } |
| 1323 | unregisterAll(); |
| 1324 | m_list = std::move(sr.m_list); |
| 1325 | } |
| 1326 | |
| 1327 | bool operator==(const AbstractRegistry<T_Ptr, Container>& other) { |
| 1328 | if (size() != other.size()) { |
| 1329 | return false; |
| 1330 | } |
| 1331 | for (std::size_t i = 0; i < m_list.size(); ++i) { |
| 1332 | if (m_list.at(i) != other.m_list.at(i)) { |
| 1333 | return false; |
| 1334 | } |
| 1335 | } |
| 1336 | return true; |
| 1337 | } |
| 1338 | |
| 1339 | bool operator!=(const AbstractRegistry<T_Ptr, Container>& other) { |
| 1340 | if (size() != other.size()) { |
| 1341 | return true; |
| 1342 | } |
| 1343 | for (std::size_t i = 0; i < m_list.size(); ++i) { |
| 1344 | if (m_list.at(i) != other.m_list.at(i)) { |
| 1345 | return true; |
| 1346 | } |
| 1347 | } |
| 1348 | return false; |
| 1349 | } |
| 1350 | |
| 1351 | /// @brief Assignment move operator |
| 1352 | AbstractRegistry& operator=(AbstractRegistry&& sr) { |
| 1353 | if (this == &sr) { |
| 1354 | return *this; |
| 1355 | } |
| 1356 | unregisterAll(); |
| 1357 | m_list = std::move(sr.m_list); |
| 1358 | return *this; |
| 1359 | } |
| 1360 | |
| 1361 | virtual ~AbstractRegistry(void) { |
| 1362 | } |
| 1363 | |
| 1364 | /// @return Iterator pointer from start of repository |
| 1365 | virtual inline iterator begin(void) ELPP_FINAL { |
| 1366 | return m_list.begin(); |
| 1367 | } |