aGrUM  0.16.0
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. More...
 
 NameGenerator (const NameGenerator &source)
 Copy constructor. More...
 
virtual ~NameGenerator ()
 Destructor. More...
 
NameGeneratoroperator= (const NameGenerator &source)
 Affectation operator. More...
 
std::string nextName (PRMObject::prm_type type)
 Getters and setters. More...
 

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 53 of file nameGenerator.h.

Constructor & Destructor Documentation

◆ NameGenerator() [1/2]

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

Default constructor.

Definition at line 34 of file nameGenerator_inl.h.

34  : __counters(3, 1) {
35  GUM_CONSTRUCTOR(NameGenerator);
36  }
std::vector< Size > __counters
The vector of counters.
Definition: nameGenerator.h:81
NameGenerator()
Default constructor.

◆ NameGenerator() [2/2]

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

Copy constructor.

Definition at line 39 of file nameGenerator_inl.h.

39  :
40  __counters(source.__counters) {
41  GUM_CONS_CPY(NameGenerator);
42  }
std::vector< Size > __counters
The vector of counters.
Definition: nameGenerator.h:81
NameGenerator()
Default constructor.

◆ ~NameGenerator()

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

Destructor.

Definition at line 45 of file nameGenerator_inl.h.

45 { GUM_DESTRUCTOR(NameGenerator); }
NameGenerator()
Default constructor.

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

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.

54  {
55  std::stringstream s;
56 
57  switch (type) {
60  s << "class_" << ++(__counters[0]);
61  break;
62  }
63 
65  s << "iface_" << ++(__counters[0]);
66  break;
67  }
68 
70  s << "sys_" << ++(__counters[0]);
71  break;
72  }
73 
75  s << "type_" << ++(__counters[0]);
76  break;
77  }
78 
80  s << "elt_" << ++(__counters[1]);
81  break;
82  }
83 
85  s << "inst_" << ++(__counters[2]);
86  break;
87  }
88 
89  default: {
90  GUM_ERROR(FatalError, "unknown PRMObject type");
91  }
92  }
93 
94  return s.str();
95  }
std::vector< Size > __counters
The vector of counters.
Definition: nameGenerator.h:81
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55

◆ operator=()

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

Affectation operator.

Definition at line 48 of file nameGenerator_inl.h.

References __counters.

48  {
49  __counters = source.__counters;
50  return *this;
51  }
std::vector< Size > __counters
The vector of counters.
Definition: nameGenerator.h:81

Member Data Documentation

◆ __counters

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

The vector of counters.

Definition at line 81 of file nameGenerator.h.

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


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