aGrUM  0.13.2
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 50 of file nameGenerator.h.

Constructor & Destructor Documentation

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

Default constructor.

Definition at line 31 of file nameGenerator_inl.h.

31  : __counters(3, 1) {
32  GUM_CONSTRUCTOR(NameGenerator);
33  }
std::vector< Size > __counters
The vector of counters.
Definition: nameGenerator.h:78
NameGenerator()
Default constructor.
INLINE gum::prm::NameGenerator::NameGenerator ( const NameGenerator source)

Copy constructor.

Definition at line 36 of file nameGenerator_inl.h.

36  :
37  __counters(source.__counters) {
38  GUM_CONS_CPY(NameGenerator);
39  }
std::vector< Size > __counters
The vector of counters.
Definition: nameGenerator.h:78
NameGenerator()
Default constructor.
INLINE gum::prm::NameGenerator::~NameGenerator ( )
virtual

Destructor.

Definition at line 42 of file nameGenerator_inl.h.

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

Member Function Documentation

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 51 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.

51  {
52  std::stringstream s;
53 
54  switch (type) {
57  s << "class_" << ++(__counters[0]);
58  break;
59  }
60 
62  s << "iface_" << ++(__counters[0]);
63  break;
64  }
65 
67  s << "sys_" << ++(__counters[0]);
68  break;
69  }
70 
72  s << "type_" << ++(__counters[0]);
73  break;
74  }
75 
77  s << "elt_" << ++(__counters[1]);
78  break;
79  }
80 
82  s << "inst_" << ++(__counters[2]);
83  break;
84  }
85 
86  default: { GUM_ERROR(FatalError, "unknown PRMObject type"); }
87  }
88 
89  return s.str();
90  }
std::vector< Size > __counters
The vector of counters.
Definition: nameGenerator.h:78
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66
INLINE NameGenerator & gum::prm::NameGenerator::operator= ( const NameGenerator source)

Affectation operator.

Definition at line 45 of file nameGenerator_inl.h.

References __counters.

45  {
46  __counters = source.__counters;
47  return *this;
48  }
std::vector< Size > __counters
The vector of counters.
Definition: nameGenerator.h:78

Member Data Documentation

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

The vector of counters.

Definition at line 78 of file nameGenerator.h.

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


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