Bayeux  3.4.1
Core Foundation library for SuperNEMO
Public Member Functions | Static Public Member Functions | List of all members
datatools::i_named Class Referenceabstract

A pure abstract class (interface) for named objects, possibly with dynamic name. Example: a class with fixed name. More...

#include <bayeux/datatools/i_named.h>

Public Member Functions

virtual std::string fetch_name () const =0
 

Static Public Member Functions

static const std::string & explicit_anonymous_label ()
 Return the explicit anonymous label. More...
 
static bool is_named (const i_named &)
 Check if the name is set. More...
 
static bool is_unnamed (const i_named &)
 Check if the name is not set. More...
 
static bool is_nameless (const i_named &)
 Check if the name is not set. More...
 
static bool is_anonymous (const i_named &)
 Check if the name is not set or explicitely anonymous. More...
 

Detailed Description

A pure abstract class (interface) for named objects, possibly with dynamic name. Example: a class with fixed name.

class foo_with_name : public datatools::i_named {
public:
foo_with_named(const std::string & name_) : _name_(name_) {}
std::string fetch_name() const { return _name_; }
private:
std::string _name_;
};

Example: a class with dynamic name

class foo_with_dynamic_name : public datatools::i_named {
public:
foo_with_dynamic_name(const std::string & prefix_, std::size_t index_)
: _prefix_(prefix_), _index_(index_) {}
std::string fetch_name() const {
std::ostringstream name_ss;
name_ss << _prefix_ << _index_;
return name_ss.str();
}
private:
std::string _prefix_;
std::size_t _index_;
};

Member Function Documentation

◆ explicit_anonymous_label()

static const std::string& datatools::i_named::explicit_anonymous_label ( )
static

Return the explicit anonymous label.

◆ fetch_name()

virtual std::string datatools::i_named::fetch_name ( ) const
pure virtual

Return the name of an object

Returns
the name associated to the object

◆ is_anonymous()

static bool datatools::i_named::is_anonymous ( const i_named )
static

Check if the name is not set or explicitely anonymous.

◆ is_named()

static bool datatools::i_named::is_named ( const i_named )
static

Check if the name is set.

◆ is_nameless()

static bool datatools::i_named::is_nameless ( const i_named )
static

Check if the name is not set.

◆ is_unnamed()

static bool datatools::i_named::is_unnamed ( const i_named )
static

Check if the name is not set.


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