aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
gum::prm::NameGenerator Class Reference

This is a name generator for classes, types, systems, instances and class elements. More...

#include <agrum/PRM/generator/PRMGenerator.h>

Public Member Functions

Constructors and destructor.
 NameGenerator ()
 Default constructor.
 NameGenerator (const NameGenerator &source)
 Copy constructor.
virtual ~NameGenerator ()
 Destructor.
NameGeneratoroperator= (const NameGenerator &source)
 Affectation operator.
std::string nextName (PRMObject::prm_type type)
 Getters and setters.

Private Attributes

std::vector< Size_counters_
 The vector of counters.

Detailed Description

This is a name generator for classes, types, systems, instances and class elements.

The generation simply use an unsigned int starting at 1 and increasing for each new name. Different numbers are used for each different type of PRMObject.

Definition at line 74 of file nameGenerator.h.

Constructor & Destructor Documentation

◆ NameGenerator() [1/2]

INLINE gum::prm::NameGenerator::NameGenerator ( )

Default constructor.

Definition at line 54 of file nameGenerator_inl.h.

54: _counters_(3, 1) { GUM_CONSTRUCTOR(NameGenerator); }
NameGenerator()
Default constructor.
std::vector< Size > _counters_
The vector of counters.

References NameGenerator(), and _counters_.

Referenced by NameGenerator(), NameGenerator(), ~NameGenerator(), and operator=().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ NameGenerator() [2/2]

INLINE gum::prm::NameGenerator::NameGenerator ( const NameGenerator & source)

Copy constructor.

Definition at line 56 of file nameGenerator_inl.h.

56 :
57 _counters_(source._counters_) {
58 GUM_CONS_CPY(NameGenerator);
59 }

References NameGenerator(), and _counters_.

Here is the call graph for this function:

◆ ~NameGenerator()

INLINE gum::prm::NameGenerator::~NameGenerator ( )
virtual

Destructor.

Definition at line 61 of file nameGenerator_inl.h.

61 {
62 GUM_DESTRUCTOR(NameGenerator);
63 ;
64 }

References NameGenerator().

Here is the call graph for this function:

Member Function Documentation

◆ nextName()

INLINE std::string gum::prm::NameGenerator::nextName ( PRMObject::prm_type type)

Getters and setters.

Returns the next name w.r.t. the given PRMType.

Definition at line 73 of file nameGenerator_inl.h.

73 {
74 std::stringstream s;
75
76 switch (type) {
79 s << "class_" << ++(_counters_[0]);
80 break;
81 }
82
84 s << "iface_" << ++(_counters_[0]);
85 break;
86 }
87
89 s << "sys_" << ++(_counters_[0]);
90 break;
91 }
92
94 s << "type_" << ++(_counters_[0]);
95 break;
96 }
97
99 s << "elt_" << ++(_counters_[1]);
100 break;
101 }
102
104 s << "inst_" << ++(_counters_[2]);
105 break;
106 }
107
108 default : {
109 GUM_ERROR(FatalError, "unknown PRMObject type")
110 }
111 }
112
113 return s.str();
114 }
#define GUM_ERROR(type, msg)
Definition exceptions.h:72

References _counters_, gum::prm::PRMObject::ALL, gum::prm::PRMObject::CLASS, gum::prm::PRMObject::CLASS_ELT, GUM_ERROR, gum::prm::PRMObject::INSTANCE, gum::prm::PRMObject::PRM_INTERFACE, gum::prm::PRMObject::SYSTEM, and gum::prm::PRMObject::TYPE.

◆ operator=()

INLINE NameGenerator & gum::prm::NameGenerator::operator= ( const NameGenerator & source)

Affectation operator.

Definition at line 67 of file nameGenerator_inl.h.

67 {
68 _counters_ = source._counters_;
69 return *this;
70 }

References NameGenerator(), and _counters_.

Here is the call graph for this function:

Member Data Documentation

◆ _counters_

std::vector< Size > gum::prm::NameGenerator::_counters_
private

The vector of counters.

Definition at line 103 of file nameGenerator.h.

Referenced by NameGenerator(), NameGenerator(), nextName(), and operator=().


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