Electroneum
el::base::utils::RegistryWithPred< T_Ptr, Pred > Class Template Reference

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

#include <easylogging++.h>

Inheritance diagram for el::base::utils::RegistryWithPred< T_Ptr, Pred >:
Collaboration diagram for el::base::utils::RegistryWithPred< T_Ptr, Pred >:

Public Types

typedef RegistryWithPred< T_Ptr, Pred >::iterator iterator
 
typedef RegistryWithPred< T_Ptr, Pred >::const_iterator const_iterator
 
- Public Types inherited from el::base::utils::AbstractRegistry< T_Ptr, std::vector< T_Ptr *> >
typedef std::vector< T_Ptr * > ::iterator iterator
 
typedef std::vector< T_Ptr * > ::const_iterator const_iterator
 

Public Member Functions

 RegistryWithPred (void)
 
virtual ~RegistryWithPred (void)
 
 RegistryWithPred (const RegistryWithPred &sr)
 Copy constructor that is useful for base classes. Try to avoid this constructor, use move constructor. More...
 
RegistryWithPredoperator= (const RegistryWithPred &sr)
 Assignment operator that unregisters all the existing registeries and deeply copies each of repo element. More...
 
- Public Member Functions inherited from el::base::utils::AbstractRegistry< T_Ptr, std::vector< 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::vector< T_Ptr * > > &other)
 
bool operator!= (const AbstractRegistry< T_Ptr, std::vector< 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::vector< T_Ptr * > & list (void) ELPP_FINAL
 Returns underlying container by reference. More...
 
virtual const std::vector< 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 unregister (T_Ptr *&ptr) ELPP_FINAL
 
virtual void registerNew (T_Ptr *ptr) ELPP_FINAL
 
template<typename T , typename T2 >
T_Ptr * get (const T &arg1, const T2 arg2)
 Gets pointer from repository with speicifed arguments. Arguments are passed to predicate in order to validate pointer. More...
 
- Protected Member Functions inherited from el::base::utils::AbstractRegistry< T_Ptr, std::vector< T_Ptr *> >
virtual void deepCopy (const AbstractRegistry< T_Ptr, std::vector< T_Ptr * > > &)=0
 
void reinitDeepCopy (const AbstractRegistry< T_Ptr, std::vector< T_Ptr * > > &sr)
 
- Protected Member Functions inherited from el::base::threading::ThreadSafe
 ThreadSafe (void)
 
virtual ~ThreadSafe (void)
 

Friends

base::type::ostream_toperator<< (base::type::ostream_t &os, const RegistryWithPred &sr)
 

Detailed Description

template<typename T_Ptr, typename Pred>
class el::base::utils::RegistryWithPred< T_Ptr, Pred >

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

NOTE: This is thread-unsafe implementation of AbstractRegistry<T_Ptr, Container>. Any implementation of this class should be made thread-safe explicitly

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

Member Typedef Documentation

◆ const_iterator

template<typename T_Ptr, typename Pred>
typedef RegistryWithPred<T_Ptr, Pred>::const_iterator el::base::utils::RegistryWithPred< T_Ptr, Pred >::const_iterator

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

◆ iterator

template<typename T_Ptr, typename Pred>
typedef RegistryWithPred<T_Ptr, Pred>::iterator el::base::utils::RegistryWithPred< T_Ptr, Pred >::iterator

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

Constructor & Destructor Documentation

◆ RegistryWithPred() [1/2]

template<typename T_Ptr, typename Pred>
el::base::utils::RegistryWithPred< T_Ptr, Pred >::RegistryWithPred ( void  )
inline

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

1474  {
1475  }

◆ ~RegistryWithPred()

template<typename T_Ptr, typename Pred>
virtual el::base::utils::RegistryWithPred< T_Ptr, Pred >::~RegistryWithPred ( void  )
inlinevirtual

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

1477  {
1478  unregisterAll();
1479  }
virtual void unregisterAll(void) ELPP_FINAL
Unregisters all the pointers from current repository.

◆ RegistryWithPred() [2/2]

template<typename T_Ptr, typename Pred>
el::base::utils::RegistryWithPred< T_Ptr, Pred >::RegistryWithPred ( const RegistryWithPred< T_Ptr, Pred > &  sr)
inline

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

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

1482  : AbstractRegistry<T_Ptr, std::vector<T_Ptr*>>() {
1483  if (this == &sr) {
1484  return;
1485  }
1486  this->reinitDeepCopy(sr);
1487  }
void reinitDeepCopy(const AbstractRegistry< T_Ptr, std::vector< T_Ptr * > > &sr)

Member Function Documentation

◆ get()

template<typename T_Ptr, typename Pred>
template<typename T , typename T2 >
T_Ptr* el::base::utils::RegistryWithPred< T_Ptr, Pred >::get ( const T arg1,
const T2  arg2 
)
inlineprotected

Gets pointer from repository with speicifed arguments. Arguments are passed to predicate in order to validate pointer.

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

1539  {
1540  iterator iter = std::find_if(this->list().begin(), this->list().end(), Pred(arg1, arg2));
1541  if (iter != this->list().end() && *iter != nullptr) {
1542  return *iter;
1543  }
1544  return nullptr;
1545  }
virtual std::vector< T_Ptr * > & list(void) ELPP_FINAL
Returns underlying container by reference.
RegistryWithPred< T_Ptr, Pred >::iterator iterator

◆ operator=()

template<typename T_Ptr, typename Pred>
RegistryWithPred& el::base::utils::RegistryWithPred< T_Ptr, Pred >::operator= ( const RegistryWithPred< T_Ptr, Pred > &  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 1492 of file easylogging++.h.

1492  {
1493  if (this == &sr) {
1494  return *this;
1495  }
1496  this->reinitDeepCopy(sr);
1497  return *this;
1498  }
void reinitDeepCopy(const AbstractRegistry< T_Ptr, std::vector< T_Ptr * > > &sr)

◆ registerNew()

template<typename T_Ptr, typename Pred>
virtual void el::base::utils::RegistryWithPred< T_Ptr, Pred >::registerNew ( T_Ptr *  ptr)
inlineprotectedvirtual

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

1532  {
1533  this->list().push_back(ptr);
1534  }
virtual std::vector< T_Ptr * > & list(void) ELPP_FINAL
Returns underlying container by reference.

◆ unregister()

template<typename T_Ptr, typename Pred>
virtual void el::base::utils::RegistryWithPred< T_Ptr, Pred >::unregister ( T_Ptr *&  ptr)
inlineprotectedvirtual

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

1517  {
1518  if (ptr) {
1519  iterator iter = this->begin();
1520  for (; iter != this->end(); ++iter) {
1521  if (ptr == *iter) {
1522  break;
1523  }
1524  }
1525  if (iter != this->end() && *iter != nullptr) {
1526  this->list().erase(iter);
1527  base::utils::safeDelete(*iter);
1528  }
1529  }
1530  }
virtual std::vector< T_Ptr * > & list(void) ELPP_FINAL
Returns underlying container by reference.
RegistryWithPred< T_Ptr, Pred >::iterator iterator

◆ unregisterAll()

template<typename T_Ptr, typename Pred>
virtual void el::base::utils::RegistryWithPred< T_Ptr, Pred >::unregisterAll ( void  )
inlineprotectedvirtual

Unregisters all the pointers from current repository.

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

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

1508  {
1509  if (!this->empty()) {
1510  for (auto&& curr : this->list()) {
1511  base::utils::safeDelete(curr);
1512  }
1513  this->list().clear();
1514  }
1515  }
virtual std::vector< T_Ptr * > & list(void) ELPP_FINAL
Returns underlying container by reference.
Here is the caller graph for this function:

Friends And Related Function Documentation

◆ operator<<

template<typename T_Ptr, typename Pred>
base::type::ostream_t& operator<< ( base::type::ostream_t os,
const RegistryWithPred< T_Ptr, Pred > &  sr 
)
friend

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

1500  {
1501  for (const_iterator it = sr.list().begin(); it != sr.list().end(); ++it) {
1502  os << ELPP_LITERAL(" ") << **it << ELPP_LITERAL("\n");
1503  }
1504  return os;
1505  }
#define ELPP_LITERAL(txt)
RegistryWithPred< T_Ptr, Pred >::const_iterator const_iterator

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