All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HSEP::Dictionary< T > Class Template Reference

Provides a pair container where the key is a string and the content element is a pointer to a template definition. More...

#include <Dictionary.h>

+ Inheritance diagram for HSEP::Dictionary< T >:
+ Collaboration diagram for HSEP::Dictionary< T >:

Public Types

typedef function< void(string
&pKeyRef, T *&pValuePtrRef)> 
ForEachWorker
 

Public Member Functions

 Dictionary ()
 
virtual ~Dictionary ()
 
void operator() (Dictionary &pReference)
 Copy operator() assimilates the content of the Dictionary given by reference.
 
T & ref (string &pKeyRef)
 Return a reference for the value pointed by the provided parameter.
 
T & ref (const char *pKeyPtr)
 Return a reference for the value pointed by the provided parameter.
 
T * ptr (string &pKeyRef)
 Returns a pointer to the internally stored element pointed by the provided parameter.
 
T * ptr (const char *pKeyPtr)
 Returns a pointer to the internally stored element pointed by the provided parameter.
 
bool has (string &pKeyRef)
 Indicates if the specified key corresponds to an stored element.
 
bool has (const char *pKeyPtr)
 Indicates if the specified key corresponds to an stored element.
 
void put (string &pKeyRef, T &pValueRef)
 Introduces a copy of the specified element inside the Catalog.
 
void put (const char *pKeyPtr, T &pValueRef)
 Insert a copy of the specified element inside the Catalog.
 
void put (string &pKeyRef, T *pValuePtr)
 Insert the specified pointer (not a copy or a copy of the pointed element) inside the Catalog.
 
void put (const char *pKeyPtr, T *pValuePtr)
 Insert the specified pointer (not a copy or a copy of the pointed element) inside the Catalog.
 
void erase (const char *pKeyPtr)
 Erases the specified dictionary entry according with the provided key constant value.
 
void erase (string &pKeyRef)
 Erases the specified dictionary entry according with the provided key constant value.
 
void clear ()
 Erases all the stored dictionary pairs running the delete method for each contained pointer and cleaning the internal data container.
 
bool forEach (ForEachWorker pWorker)
 Executes the given pWorker function on every contained element.
 
size_t size ()
 Returns the container size.
 
- Public Member Functions inherited from HSEP::HSEPObject
string & lastErrorRef ()
 Returns a reference to the last stored error message.
 
ErrorCode lastCode ()
 Returns the last stored code.
 
bool valid ()
 Permits to know if the object has a valid internal state.
 
string & typeRef ()
 Permits to know the type of this particular object.
 

Additional Inherited Members

- Protected Member Functions inherited from HSEP::HSEPObject
 HSEPObject (const char *pType)
 Constructor, providing the base for the state controlling instance.
 
virtual ~HSEPObject ()
 
void setLastError (string &pErrorMsgRef)
 Assigns an error message text to the last executed operation.
 
void setLastError (const string &pErrorMsgRef)
 Assigns an error message text to the last executed operation.
 
void setLastError (const char *pErrorMsg)
 Assigns an error message text to the last executed operation.
 
void setValid ()
 Defines that the object has a valid state.
 
void setInvalid ()
 Defines that the object has an invalid state.
 
void setLastCode (const ErrorCode pErrorCode)
 Defines the internal result code for the object.
 

Detailed Description

template<class T>
class HSEP::Dictionary< T >

Provides a pair container where the key is a string and the content element is a pointer to a template definition.

The idea with the Dictionary is to offer a more precise control on the contained elements, reducing memory footprint but without letting possible memory leaks because of the lack of control of a plain regular map container.

Definition at line 44 of file Dictionary.h.

Member Typedef Documentation

template<class T>
typedef function<void (string& pKeyRef, T*& pValuePtrRef)> HSEP::Dictionary< T >::ForEachWorker

Definition at line 48 of file Dictionary.h.

Constructor & Destructor Documentation

template<class T>
HSEP::Dictionary< T >::Dictionary ( )
inline

Definition at line 50 of file Dictionary.h.

template<class T>
virtual HSEP::Dictionary< T >::~Dictionary ( )
inlinevirtual

Definition at line 53 of file Dictionary.h.

Member Function Documentation

template<class T>
void HSEP::Dictionary< T >::clear ( )
inline

Erases all the stored dictionary pairs running the delete method for each contained pointer and cleaning the internal data container.

Definition at line 254 of file Dictionary.h.

Referenced by HSEPData::DB::loadDrivers(), HSEP::FileTool::retrieve(), and HSEP::DriverSet< Type >::unload().

+ Here is the caller graph for this function:

template<class T>
void HSEP::Dictionary< T >::erase ( const char *  pKeyPtr)
inline

Erases the specified dictionary entry according with the provided key constant value.

Parameters
pKeyPtrkey to find the pair will be erased

Definition at line 237 of file Dictionary.h.

template<class T>
void HSEP::Dictionary< T >::erase ( string &  pKeyRef)
inline

Erases the specified dictionary entry according with the provided key constant value.

Parameters
pKeyRefkey to find the pair will be erased

Definition at line 246 of file Dictionary.h.

template<class T>
bool HSEP::Dictionary< T >::forEach ( ForEachWorker  pWorker)
inline

Executes the given pWorker function on every contained element.

Parameters
pWorkerThe given function
Returns
true when the forEach worked on all elements without problems.
false when an exception during the traversal of the contained elements was issued.

It is possible to assign a regular C style function pointer or a lambda style function.

Definition at line 274 of file Dictionary.h.

Referenced by HSEP::DriverSet< Type >::forEach(), HSEP::DriverSet< Type >::info(), HSEP::RegexpChecker::key(), HSEP::Dictionary< DriverLibType >::operator()(), HSEP::RegexpChecker::RegexpChecker(), and HSEP::FileTool::store().

+ Here is the caller graph for this function:

template<class T>
bool HSEP::Dictionary< T >::has ( string &  pKeyRef)
inline

Indicates if the specified key corresponds to an stored element.

Parameters
pKeyRefkey to find the specified element
Returns
true when the element is stored inside the dictionary
false when the element is not stored inside the dictionary

Definition at line 148 of file Dictionary.h.

Referenced by HSEP::DriverSet< Type >::has(), HSEPData::DB::loadInstances(), and HSEP::RegexpChecker::match().

+ Here is the caller graph for this function:

template<class T>
bool HSEP::Dictionary< T >::has ( const char *  pKeyPtr)
inline

Indicates if the specified key corresponds to an stored element.

Parameters
pKeyPtrkey to find the specified element
Returns
true when the element is stored inside the dictionary
false when the element is not stored inside the dictionary

Definition at line 158 of file Dictionary.h.

template<class T>
void HSEP::Dictionary< T >::operator() ( Dictionary< T > &  pReference)
inline

Copy operator() assimilates the content of the Dictionary given by reference.

Parameters
pReference

Definition at line 62 of file Dictionary.h.

template<class T>
T* HSEP::Dictionary< T >::ptr ( string &  pKeyRef)
inline

Returns a pointer to the internally stored element pointed by the provided parameter.

Parameters
pKeyRefkey to find the specified value.
Returns
pointer to the specified value
nullptr when the specified value does not exist (doesn't create the internal element in such case).

Definition at line 120 of file Dictionary.h.

Referenced by HSEP::DriverSet< Type >::has(), and HSEP::DriverSet< Type >::ptr().

+ Here is the caller graph for this function:

template<class T>
T* HSEP::Dictionary< T >::ptr ( const char *  pKeyPtr)
inline

Returns a pointer to the internally stored element pointed by the provided parameter.

Parameters
pKeyPtrkey to find the specified value.
Returns
pointer to the specified value
nullptr when the specified value does not exist (doesn't create the internal element in such case).

Definition at line 137 of file Dictionary.h.

template<class T>
void HSEP::Dictionary< T >::put ( string &  pKeyRef,
T &  pValueRef 
)
inline

Introduces a copy of the specified element inside the Catalog.

If the specified element is already stored inside the dictionary, the original will be erased and the new element will be stored instead.

Parameters
pKeyRefkey to further find the specified element
pValueRefreference value that will be copied inside the dictionary

Definition at line 172 of file Dictionary.h.

Referenced by HSEP::DriverSet< Type >::_addLibrary(), HSEPData::QueryUniqueCycle::execute(), HSEPDataSqLite::feedMetadata(), HSEPData::DB::loadDrivers(), HSEP::RegexpChecker::RegexpChecker(), HSEP::FileTool::retrieve(), and HSEP::StringTool::split().

+ Here is the caller graph for this function:

template<class T>
void HSEP::Dictionary< T >::put ( const char *  pKeyPtr,
T &  pValueRef 
)
inline

Insert a copy of the specified element inside the Catalog.

If the specified element is already stored inside the dictionary, the original will be erased and the new element will be stored instead.

Parameters
pKeyPtrkey to further find the specified element
pValueRefreference value that will be copied inside the dictionary

Definition at line 194 of file Dictionary.h.

template<class T>
void HSEP::Dictionary< T >::put ( string &  pKeyRef,
T *  pValuePtr 
)
inline

Insert the specified pointer (not a copy or a copy of the pointed element) inside the Catalog.

If the specified element is already stored inside the dictionary, the original will be erased and the new element will be stored instead.

Parameters
pKeyRefkey to further find the specified element
pValuePtrpointer to the value that will be stored inside the dictionary

Definition at line 208 of file Dictionary.h.

template<class T>
void HSEP::Dictionary< T >::put ( const char *  pKeyPtr,
T *  pValuePtr 
)
inline

Insert the specified pointer (not a copy or a copy of the pointed element) inside the Catalog.

If the specified element is already stored inside the dictionary, the original will be erased and the new element will be stored instead.

Parameters
pKeyPtrkey to further find the specified element
pValuePtrpointer to the value that will be stored inside the dictionary

Definition at line 226 of file Dictionary.h.

template<class T>
T& HSEP::Dictionary< T >::ref ( string &  pKeyRef)
inline

Return a reference for the value pointed by the provided parameter.

As the behavior, when the an element doesn't exist can't be defined, the method throw an exception when it is called with a non existent key. When having doubts, first check about the existence of the element with the "has" method, or use the "ptr" method instead.

See Also
has
Parameters
pKeyRefkey to find the specified value.
Returns
a reference to the existing element, or a NullReferenceException if the element doesn't exist.

Definition at line 81 of file Dictionary.h.

Referenced by HSEPData::QueryUniqueCycle::getValueRef(), HSEPData::DB::loadInstances(), and HSEP::RegexpChecker::match().

+ Here is the caller graph for this function:

template<class T>
T& HSEP::Dictionary< T >::ref ( const char *  pKeyPtr)
inline

Return a reference for the value pointed by the provided parameter.

As the behavior, when the an element doesn't exist can't be defined, the method throw an exception when it is called with a non existent key. When having doubts, first check about the existence of the element with the "has" method, or use the "ptr" method instead.

See Also
has
Parameters
pKeyPtrkey to find the specified value.
Returns
a reference to the existing element, or a NullReferenceException if the element doesn't exist.

Definition at line 109 of file Dictionary.h.

template<class T>
size_t HSEP::Dictionary< T >::size ( )
inline

Returns the container size.

Returns

Definition at line 301 of file Dictionary.h.


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