aGrUM 3.0.0
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 55 of file nameGenerator_inl.h.

55: _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 57 of file nameGenerator_inl.h.

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

References NameGenerator(), and _counters_.

Here is the call graph for this function:

◆ ~NameGenerator()

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

Destructor.

Definition at line 62 of file nameGenerator_inl.h.

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

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 71 of file nameGenerator_inl.h.

71 {
72 switch (type) {
74 case PRMObject::prm_type::CLASS : return std::format("class_{}", ++(_counters_[0]));
75
76 case PRMObject::prm_type::PRM_INTERFACE : return std::format("iface_{}", ++(_counters_[0]));
77
78 case PRMObject::prm_type::SYSTEM : return std::format("sys_{}", ++(_counters_[0]));
79
80 case PRMObject::prm_type::TYPE : return std::format("type_{}", ++(_counters_[0]));
81
82 case PRMObject::prm_type::CLASS_ELT : return std::format("elt_{}", ++(_counters_[1]));
83
84 case PRMObject::prm_type::INSTANCE : return std::format("inst_{}", ++(_counters_[2]));
85
86 default : GUM_ERROR(FatalError, "unknown PRMObject type")
87 }
88 }
#define GUM_ERROR(type, msg)
Definition exceptions.h:76

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)
default

Affectation operator.

References NameGenerator().

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(), and nextName().


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