Electroneum
el::base::utils::Registry< T_Ptr, T_Key > Class Template Reference

A pointer registry mechanism to manage memory and provide search functionalities. (non-predicate version) More...

#include <easylogging++.h>

Inheritance diagram for el::base::utils::Registry< T_Ptr, T_Key >:
Collaboration diagram for el::base::utils::Registry< T_Ptr, T_Key >:

Public Types

typedef Registry< T_Ptr, T_Key >::iterator iterator
 
typedef Registry< T_Ptr, T_Key >::const_iterator const_iterator
 
- Public Types inherited from el::base::utils::AbstractRegistry< T_Ptr, std::unordered_map< T_Key, T_Ptr *> >
typedef std::unordered_map< T_Key, T_Ptr * > ::iterator iterator
 
typedef std::unordered_map< T_Key, T_Ptr * > ::const_iterator const_iterator
 

Public Member Functions

 Registry (void)
 
 Registry (const Registry &sr)
 Copy constructor that is useful for base classes. Try to avoid this constructor, use move constructor. More...
 
Registryoperator= (const Registry &sr)
 Assignment operator that unregisters all the existing registeries and deeply copies each of repo element. More...
 
virtual ~Registry (void)
 
- Public Member Functions inherited from el::base::utils::AbstractRegistry< T_Ptr, std::unordered_map< T_Key, T_Ptr *> >
 AbstractRegistry (void)
 Default constructor. More...
 
 AbstractRegistry (AbstractRegistry &&sr)
 Move constructor that is useful for base classes. More...
 
bool operator== (const AbstractRegistry< T_Ptr, std::unordered_map< T_Key, T_Ptr * > > &other)
 
bool operator!= (const AbstractRegistry< T_Ptr, std::unordered_map< T_Key, T_Ptr * > > &other)
 
AbstractRegistryoperator= (AbstractRegistry &&sr)
 Assignment move operator. More...
 
virtual ~AbstractRegistry (void)
 
virtual iterator begin (void) ELPP_FINAL
 
virtual iterator end (void) ELPP_FINAL
 
virtual const_iterator cbegin (void) const ELPP_FINAL
 
virtual const_iterator cend (void) const ELPP_FINAL
 
virtual bool empty (void) const ELPP_FINAL
 
virtual std::size_t size (void) const ELPP_FINAL
 
virtual std::unordered_map< T_Key, T_Ptr * > & list (void) ELPP_FINAL
 Returns underlying container by reference. More...
 
virtual const std::unordered_map< T_Key, T_Ptr * > & list (void) const ELPP_FINAL
 Returns underlying container by constant reference. More...
 
- Public Member Functions inherited from el::base::threading::ThreadSafe
virtual void acquireLock (void) ELPP_FINAL
 
virtual void releaseLock (void) ELPP_FINAL
 
virtual base::threading::Mutexlock (void) ELPP_FINAL
 

Protected Member Functions

virtual void unregisterAll (void) ELPP_FINAL
 Unregisters all the pointers from current repository. More...
 
virtual void registerNew (const T_Key &uniqKey, T_Ptr *ptr) ELPP_FINAL
 Registers new registry to repository. More...
 
void unregister (const T_Key &uniqKey)
 Unregisters single entry mapped to specified unique key. More...
 
T_Ptr * get (const T_Key &uniqKey)
 Gets pointer from repository. If none found, nullptr is returned. More...
 
- Protected Member Functions inherited from el::base::utils::AbstractRegistry< T_Ptr, std::unordered_map< T_Key, T_Ptr *> >
virtual void deepCopy (const AbstractRegistry< T_Ptr, std::unordered_map< T_Key, T_Ptr * > > &)=0
 
void reinitDeepCopy (const AbstractRegistry< T_Ptr, std::unordered_map< T_Key, T_Ptr * > > &sr)
 
- Protected Member Functions inherited from el::base::threading::ThreadSafe
 ThreadSafe (void)
 
virtual ~ThreadSafe (void)
 

Detailed Description

template<typename T_Ptr, typename T_Key = const char*>
class el::base::utils::Registry< T_Ptr, T_Key >

A pointer registry mechanism to manage memory and provide search functionalities. (non-predicate version)

NOTE: This is thread-unsafe implementation (although it contains lock function, it does not use these functions) of AbstractRegistry<T_Ptr, Container>. Any implementation of this class should be explicitly (by using lock functions)

Definition at line 1393 of file easylogging++.h.

Member Typedef Documentation

◆ const_iterator

template<typename T_Ptr, typename T_Key = const char*>
typedef Registry<T_Ptr, T_Key>::const_iterator el::base::utils::Registry< T_Ptr, T_Key >::const_iterator

Definition at line 1396 of file easylogging++.h.

◆ iterator

template<typename T_Ptr, typename T_Key = const char*>
typedef Registry<T_Ptr, T_Key>::iterator el::base::utils::Registry< T_Ptr, T_Key >::iterator

Definition at line 1395 of file easylogging++.h.

Constructor & Destructor Documentation

◆ Registry() [1/2]

template<typename T_Ptr, typename T_Key = const char*>
el::base::utils::Registry< T_Ptr, T_Key >::Registry ( void  )
inline

Definition at line 1398 of file easylogging++.h.

1398 {}

◆ Registry() [2/2]

template<typename T_Ptr, typename T_Key = const char*>
el::base::utils::Registry< T_Ptr, T_Key >::Registry ( const Registry< T_Ptr, T_Key > &  sr)
inline

Copy constructor that is useful for base classes. Try to avoid this constructor, use move constructor.

Definition at line 1401 of file easylogging++.h.

1401  : AbstractRegistry<T_Ptr, std::vector<T_Ptr*>>() {
1402  if (this == &sr) {
1403  return;
1404  }
1405  this->reinitDeepCopy(sr);
1406  }
void reinitDeepCopy(const AbstractRegistry< T_Ptr, std::unordered_map< T_Key, T_Ptr * > > &sr)

◆ ~Registry()

template<typename T_Ptr, typename T_Key = const char*>
virtual el::base::utils::Registry< T_Ptr, T_Key >::~Registry ( void  )
inlinevirtual

Definition at line 1419 of file easylogging++.h.

1419  {
1420  unregisterAll();
1421  }
virtual void unregisterAll(void) ELPP_FINAL
Unregisters all the pointers from current repository.

Member Function Documentation

◆ get()

template<typename T_Ptr, typename T_Key = const char*>
T_Ptr* el::base::utils::Registry< T_Ptr, T_Key >::get ( const T_Key &  uniqKey)
inlineprotected

Gets pointer from repository. If none found, nullptr is returned.

Definition at line 1449 of file easylogging++.h.

1449  {
1450  iterator it = this->list().find(uniqKey);
1451  return it == this->list().end()
1452  ? nullptr
1453  : it->second;
1454  }
virtual std::unordered_map< T_Key, T_Ptr * > & list(void) ELPP_FINAL
Returns underlying container by reference.
Registry< T_Ptr, T_Key >::iterator iterator

◆ operator=()

template<typename T_Ptr, typename T_Key = const char*>
Registry& el::base::utils::Registry< T_Ptr, T_Key >::operator= ( const Registry< T_Ptr, T_Key > &  sr)
inline

Assignment operator that unregisters all the existing registeries and deeply copies each of repo element.

See also
unregisterAll()
deepCopy(const AbstractRegistry&)

Definition at line 1411 of file easylogging++.h.

1411  {
1412  if (this == &sr) {
1413  return *this;
1414  }
1415  this->reinitDeepCopy(sr);
1416  return *this;
1417  }
void reinitDeepCopy(const AbstractRegistry< T_Ptr, std::unordered_map< T_Key, T_Ptr * > > &sr)

◆ registerNew()

template<typename T_Ptr, typename T_Key = const char*>
virtual void el::base::utils::Registry< T_Ptr, T_Key >::registerNew ( const T_Key &  uniqKey,
T_Ptr *  ptr 
)
inlineprotectedvirtual

Registers new registry to repository.

Definition at line 1434 of file easylogging++.h.

1434  {
1435  unregister(uniqKey);
1436  this->list().insert(std::make_pair(uniqKey, ptr));
1437  }
virtual std::unordered_map< T_Key, T_Ptr * > & list(void) ELPP_FINAL
Returns underlying container by reference.
void unregister(const T_Key &uniqKey)
Unregisters single entry mapped to specified unique key.

◆ unregister()

template<typename T_Ptr, typename T_Key = const char*>
void el::base::utils::Registry< T_Ptr, T_Key >::unregister ( const T_Key &  uniqKey)
inlineprotected

Unregisters single entry mapped to specified unique key.

Definition at line 1440 of file easylogging++.h.

1440  {
1441  T_Ptr* existing = get(uniqKey);
1442  if (existing != nullptr) {
1443  this->list().erase(uniqKey);
1444  base::utils::safeDelete(existing);
1445  }
1446  }
virtual std::unordered_map< T_Key, T_Ptr * > & list(void) ELPP_FINAL
Returns underlying container by reference.
Here is the caller graph for this function:

◆ unregisterAll()

template<typename T_Ptr, typename T_Key = const char*>
virtual void el::base::utils::Registry< T_Ptr, T_Key >::unregisterAll ( void  )
inlineprotectedvirtual

Unregisters all the pointers from current repository.

Implements el::base::utils::AbstractRegistry< T_Ptr, std::unordered_map< T_Key, T_Ptr *> >.

Definition at line 1424 of file easylogging++.h.

1424  {
1425  if (!this->empty()) {
1426  for (auto&& curr : this->list()) {
1427  base::utils::safeDelete(curr.second);
1428  }
1429  this->list().clear();
1430  }
1431  }
virtual std::unordered_map< T_Key, T_Ptr * > & list(void) ELPP_FINAL
Returns underlying container by reference.
Here is the caller graph for this function:

The documentation for this class was generated from the following file: