PARTONS  
PARtonic Tomography Of Nucleon Software
Public Member Functions | Protected Attributes | List of all members
PARTONS::List< T > Class Template Reference

STL-like container to store basic PARTONS objects. More...

Inheritance diagram for PARTONS::List< T >:
PARTONS::BaseObject

Public Member Functions

 List ()
 Constructor. More...
 
 List (std::vector< T > &stdVector)
 Assignment constructor. More...
 
virtual ~List ()
 Destructor. More...
 
virtual void add (const T &data)
 Add new element. More...
 
void add (const List< T > &list)
 Add list of new elements. More...
 
void add (const std::vector< T > &vector)
 Add vector of new elements. More...
 
const T & get (size_t n) const
 Get reference to element of given index. More...
 
T & operator[] (size_t n)
 Get reference to element of given index. More...
 
const T & operator[] (size_t n) const
 Get reference to element of given index. More...
 
size_t size () const
 Get size of this list. More...
 
bool isEmpty () const
 Check if list is empty. More...
 
std::string toString ()
 Return a pre-formatted characters string for output visualization of class member's values. More...
 
void sort ()
 Sort elements of this list. More...
 
std::vector< T > getData () const
 Get vector containing stored elements. More...
 
void compare (ComparisonReport &rootComparisonReport, const List< T > &referenceObject, const ComparisonMode &comparisonMode=ComparisonMode::EQUAL, std::string parentObjectInfo=ElemUtils::StringUtils::EMPTY) const
 Compare to other List and store comparison result in given comparison report. More...
 
void clear ()
 Clear list. More...
 
void resize (size_t n)
 Resize list to given size. More...
 
void removeLast ()
 Remove the last element from this list. More...
 
const T & getLast () const
 Get the last element of this list. More...
 
void serialize (ElemUtils::Packet &packet) const
 Used to split a complex C++ object into a concatenation of simple types. More...
 
void unserialize (ElemUtils::Packet &packet)
 Used to rebuild a complex C++ object from a concatenation of simple type. More...
 
- Public Member Functions inherited from PARTONS::BaseObject
 BaseObject (const std::string &className)
 Constructor. More...
 
virtual ~BaseObject ()
 Default destructor. More...
 
virtual BaseObjectclone () const
 Virtual clone function to allow the factory to clone all derived members object stored in the BaseObjectRegistry. More...
 
virtual void resolveObjectDependencies ()
 Because of the initialization step order of the program, objects are registered in a total random order and some objects depend on others. More...
 
virtual std::string toString () const
 Return a pre-formatted characters string for output visualization of class member's values. More...
 
void serialize (ElemUtils::Packet &packet) const
 Used to split a complex C++ object into a concatenation of simple types. More...
 
void unserialize (ElemUtils::Packet &packet)
 Used to rebuild a complex C++ object from a concatenation of simple type. More...
 
bool operator< (const BaseObject &other) const
 Overload of < operator to sort BaseObject object by its indexId value. More...
 
const std::string & getClassName () const
 
unsigned int getObjectId () const
 
int getIndexId () const
 
void setIndexId (int indexId)
 

Protected Attributes

std::vector< T > m_data
 Elements of this list. More...
 

Additional Inherited Members

- Protected Member Functions inherited from PARTONS::BaseObject
 BaseObject (const BaseObject &other)
 Copy constructor. More...
 
void info (const std::string &functionName, const std::string &message) const
 Print info message into logger. More...
 
void debug (const std::string &functionName, const std::string &message) const
 Print debug message into logger. More...
 
void warn (const std::string &functionName, const std::string &message) const
 Print warning message into logger. More...
 
void errorMissingParameter (const std::string &parameterName) const
 Use in automation process to throw exception when a parameter is missing from the XML scenario file. More...
 

Detailed Description

template<class T>
class PARTONS::List< T >

STL-like container to store basic PARTONS objects.

This class is a STL-like container created in order to store PARTONS objects that derivative from BaseObject class. More precisely, it is a wrap of std::vector that provides additional functionalities, like sorting and serialization, all based on functions predefined in BaseObject class. This example illustrates how to use this container:

//define two lists of GPDResult objects
List<GPDResult> list1;
List<GPDResult> list2;
//fill these lists with few objects
//retrieve GPD service
GPDService* pGPDService =
//load GPD module with the BaseModuleFactory
GPDModule* pGPDModel =
MMS13Model::classId);
//define list of GPD types to be computed
List<GPDType> gpdTypeList;
gpdTypeList.add(GPDType::H);
//get four examples
for (size_t i = 0; i < 4; i++) {
//evaluate
GPDResult gpdResult = pGPDService->computeGPDModel(
GPDKinematic(-0.1 + 0.05 * i, 0.05, 0., 2., 2.), pGPDModel,
gpdTypeList);
//fill lists
list1.add(gpdResult);
list2.add(gpdResult);
}
//compare lists
ComparisonReport comparisonReport1(NumA::Tolerances(0.001, 0.001));
list1.compare(comparisonReport1, list2);
//print comparison results
Partons::getInstance()->getLoggerManager()->info("example", __func__, ElemUtils::Formatter() << "Comparison report: " << comparisonReport1.toString());
@ H
Twist-2 GPD .
Definition: GPDType.h:46
GPDModule * newGPDModule(unsigned int classId)
Specialization of ModuleObjectFactory::newModuleObject into a GPDModule.
Definition: ModuleObjectFactory.cpp:173
ElemUtils::LoggerManager * getLoggerManager() const
Definition: Partons.cpp:191
static Partons * getInstance()
Share a unique pointer of this class.
Definition: Partons.cpp:27
ModuleObjectFactory * getModuleObjectFactory() const
Definition: Partons.cpp:187
ServiceObjectRegistry * getServiceObjectRegistry() const
Definition: Partons.cpp:179
GPDService * getGPDService() const
Definition: ServiceObjectRegistry.cpp:54

which gives via Logger:

20-05-2017 11:37:21 [INFO] (example::main) Comparison report:
[Environment setting]
Linux partons 3.2.0-4-amd64 #1 SMP Debian 3.2.73-2+deb7u2 x86_64 GNU/Linux
g++ (Debian 4.7.2-5) 4.7.2
GSL 1.16
ROOT 5.34.32
CLN 1.3.4
SFML 2.3.2
QT 4.8.3
PARTONS Revision: 728
NumA++ Revision: 728
[Objects compared]
compared to
[Tolerances]
Absolute tolerance = 0.001
Relative tolerance = 0.001
Number of objects compared with test PASSED = 40
Number of objects compared with test FAILED = 0
Definition: DVCSCFFDispersionRelation.h:20
Definition: BaseObject.cpp:11

Constructor & Destructor Documentation

◆ List() [1/2]

template<class T >
PARTONS::List< T >::List ( )
inline

Constructor.

◆ List() [2/2]

template<class T >
PARTONS::List< T >::List ( std::vector< T > &  stdVector)
inline

Assignment constructor.

Parameters
stdVectorVector storing values to be assigned.

◆ ~List()

template<class T >
virtual PARTONS::List< T >::~List ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ add() [1/3]

template<class T >
void PARTONS::List< T >::add ( const List< T > &  list)
inline

Add list of new elements.

Parameters
listList of elements to be added.

◆ add() [2/3]

template<class T >
void PARTONS::List< T >::add ( const std::vector< T > &  vector)
inline

Add vector of new elements.

Parameters
listVector of elements to be added.

◆ add() [3/3]

template<class T >
virtual void PARTONS::List< T >::add ( const T &  data)
inlinevirtual

Add new element.

◆ clear()

template<class T >
void PARTONS::List< T >::clear ( )
inline

Clear list.

◆ compare()

template<class T >
void PARTONS::List< T >::compare ( ComparisonReport rootComparisonReport,
const List< T > &  referenceObject,
const ComparisonMode comparisonMode = ComparisonMode::EQUAL,
std::string  parentObjectInfo = ElemUtils::StringUtils::EMPTY 
) const
inline

Compare to other List and store comparison result in given comparison report.

Parameters
rootComparisonReportReference to comparison report to be used to store comparison result.
referenceObjectReference to List to be compared.
comparisonModeMode of comparison, see documentation of ComparisonMode class.
parentObjectInfoAddition information coming from the parent object (if needed).

◆ get()

template<class T >
const T& PARTONS::List< T >::get ( size_t  n) const
inline

Get reference to element of given index.

Parameters
nIndex of requested element.
Returns
Reference to requested element.

◆ getData()

template<class T >
std::vector<T> PARTONS::List< T >::getData ( ) const
inline

Get vector containing stored elements.

Returns
Vector containing stored elements

◆ getLast()

template<class T >
const T& PARTONS::List< T >::getLast ( ) const
inline

Get the last element of this list.

Returns
Requested element.

◆ isEmpty()

template<class T >
bool PARTONS::List< T >::isEmpty ( ) const
inline

Check if list is empty.

Returns
True if list is empty, otherwise false.

◆ operator[]() [1/2]

template<class T >
T& PARTONS::List< T >::operator[] ( size_t  n)
inline

Get reference to element of given index.

Parameters
nIndex of requested element.
Returns
Reference to requested element.

◆ operator[]() [2/2]

template<class T >
const T& PARTONS::List< T >::operator[] ( size_t  n) const
inline

Get reference to element of given index.

Parameters
nIndex of requested element.
Returns
Reference to requested element.

◆ removeLast()

template<class T >
void PARTONS::List< T >::removeLast ( )
inline

Remove the last element from this list.

◆ resize()

template<class T >
void PARTONS::List< T >::resize ( size_t  n)
inline

Resize list to given size.

Parameters
nSize to be set.

◆ serialize()

template<class T >
void PARTONS::List< T >::serialize ( ElemUtils::Packet &  packet) const
inline

Used to split a complex C++ object into a concatenation of simple types.

Parameters
packetTarget Packet.

◆ size()

template<class T >
size_t PARTONS::List< T >::size ( ) const
inline

Get size of this list.

Returns
Size of this list.

◆ sort()

template<class T >
void PARTONS::List< T >::sort ( )
inline

Sort elements of this list.

◆ toString()

template<class T >
std::string PARTONS::List< T >::toString ( )
inline

Return a pre-formatted characters string for output visualization of class member's values.

Returns
A pre-formatted characters string.

◆ unserialize()

template<class T >
void PARTONS::List< T >::unserialize ( ElemUtils::Packet &  packet)
inline

Used to rebuild a complex C++ object from a concatenation of simple type.

Parameters
packetInput Packet.

Member Data Documentation

◆ m_data

template<class T >
std::vector<T> PARTONS::List< T >::m_data
protected

Elements of this list.


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