ATLAS Offline Software
Public Types | Public Member Functions | Private Types | Private Attributes | Related Functions | List of all members
SH::TagList Class Reference

A class that manages a list of tags for identifying samples. More...

#include <TagList.h>

Collaboration diagram for SH::TagList:

Public Types

typedef std::set< std::string >::const_iterator iterator
 the iterator to use More...
 

Public Member Functions

void testInvariant () const
 test the invariant of this object More...
 
 TagList ()
 standard default constructor More...
 
 TagList (const std::string &tags, char separator=':')
 create a tag-list from a string More...
 
bool has (const std::string &tag) const
 whether we have the given tag More...
 
iterator begin () const
 the begin iterator to use More...
 
iterator end () const
 the end iterator to use More...
 
std::string join (char separator=':') const
 join all the tags together into a string More...
 
void add (const std::string &tag)
 add a tag to the list More...
 

Private Types

typedef std::set< std::string >::const_iterator TagsIter
 the iterator for m_tags More...
 

Private Attributes

std::set< std::string > m_tags
 the list of tags More...
 

Related Functions

(Note that these are not member functions.)

std::string dbg (const TagList &obj, unsigned verbosity=0)
 the debugging info of this object More...
 

Detailed Description

A class that manages a list of tags for identifying samples.

The idea is to use the marker to group samples according to their type. This is a bit of an old mechanism, and personally I prefer to rely on meta-data instead.

Definition at line 47 of file TagList.h.

Member Typedef Documentation

◆ iterator

typedef std::set<std::string>::const_iterator SH::TagList::iterator

the iterator to use

Definition at line 96 of file TagList.h.

◆ TagsIter

typedef std::set<std::string>::const_iterator SH::TagList::TagsIter
private

the iterator for m_tags

Definition at line 150 of file TagList.h.

Constructor & Destructor Documentation

◆ TagList() [1/2]

SH::TagList::TagList ( )

standard default constructor

Guarantee
strong
Failures
out of memory I

Definition at line 59 of file TagList.cxx.

61  {
62  RCU_NEW_INVARIANT (this);
63  }

◆ TagList() [2/2]

SH::TagList::TagList ( const std::string &  tags,
char  separator = ':' 
)
explicit

create a tag-list from a string

param tags the given list of tags param separator the character by which tags are separated in the list

Guarantee
strong
Failures
out of memory II

Definition at line 67 of file TagList.cxx.

69  {
70  std::string::const_iterator pos1, pos2 = tags.begin(), end = tags.end();
71 
72  while (pos2 != end)
73  {
74  for (pos1 = pos2; pos2 != end && *pos2 != separator; ++ pos2) {};
75 
76  if (pos2 != pos1)
77  m_tags.insert (std::string (pos1, pos2));
78  if (pos2 != end)
79  ++ pos2;
80  };
81 
82  RCU_NEW_INVARIANT (this);
83  }

Member Function Documentation

◆ add()

void SH::TagList::add ( const std::string &  tag)

add a tag to the list

Parameters
tagthe tag to add
Guarantee
strong
Failures
out of memory II

Definition at line 135 of file TagList.cxx.

137  {
138  RCU_CHANGE_INVARIANT (this);
139 
140  m_tags.insert (tag);
141  }

◆ begin()

TagList::iterator SH::TagList::begin ( ) const

the begin iterator to use

Guarantee
no-fail

Definition at line 97 of file TagList.cxx.

99  {
100  RCU_READ_INVARIANT (this);
101  return m_tags.begin();
102  }

◆ end()

TagList::iterator SH::TagList::end ( ) const

the end iterator to use

Guarantee
no-fail

Definition at line 106 of file TagList.cxx.

108  {
109  RCU_READ_INVARIANT (this);
110  return m_tags.end();
111  }

◆ has()

bool SH::TagList::has ( const std::string &  tag) const

whether we have the given tag

Returns
whether we have the given tag
Precondition
!tag.empty()
Guarantee
no-fail

Definition at line 87 of file TagList.cxx.

89  {
90  RCU_READ_INVARIANT (this);
91  RCU_REQUIRE_SOFT (!tag.empty());
92  return m_tags.find (tag) != m_tags.end();
93  }

◆ join()

std::string SH::TagList::join ( char  separator = ':') const

join all the tags together into a string

Returns
the joined tags
Parameters
separatorthe separator to use
Guarantee
strong
Failures
out of memory II
separator used within tag

Definition at line 115 of file TagList.cxx.

117  {
118  RCU_READ_INVARIANT (this);
119 
120  std::string result;
121  for (TagsIter tag = m_tags.begin(), end = m_tags.end();
122  tag != end; ++ tag)
123  {
124  if (tag->find (separator) != std::string::npos)
125  RCU_THROW_MSG (std::string ("can't use separator ") + separator + " it is part of tag " + *tag);
126  if (!result.empty())
127  result += separator;
128  result += *tag;
129  };
130  return result;
131  }

◆ testInvariant()

void SH::TagList::testInvariant ( ) const

test the invariant of this object

Guarantee
no-fail

Definition at line 46 of file TagList.cxx.

48  {
49  for (TagsIter tag = m_tags.begin(),
50  end = m_tags.end(); tag != end; ++ tag)
51  {
52  RCU_INVARIANT (!tag->empty());
53  //RCU_INVARIANT (tag->find (':') == std::string::npos);
54  };
55  }

Friends And Related Function Documentation

◆ dbg()

std::string dbg ( const TagList obj,
unsigned  verbosity = 0 
)
related

the debugging info of this object

Returns
a string representation of the object content
Parameters
objthe object to be presented
verbositythe level of verbosity (higher number -> more information)
Guarantee
strong
Failures
out of memory II

Definition at line 30 of file TagList.cxx.

31  {
32  std::string result;
33 
34  for (TagList::iterator tag = obj.begin(), end = obj.end();
35  tag != end; ++ tag)
36  {
37  if (!result.empty())
38  result += ",";
39  result += *tag;
40  };
41  return "(" + result + ")";
42  }

Member Data Documentation

◆ m_tags

std::set<std::string> SH::TagList::m_tags
private

the list of tags

Definition at line 146 of file TagList.h.


The documentation for this class was generated from the following files:
get_generator_info.result
result
Definition: get_generator_info.py:21
SH::TagList::TagsIter
std::set< std::string >::const_iterator TagsIter
the iterator for m_tags
Definition: TagList.h:150
tags
std::vector< std::string > tags
Definition: hcg.cxx:102
RCU_REQUIRE_SOFT
#define RCU_REQUIRE_SOFT(x)
Definition: Assert.h:153
RCU_INVARIANT
#define RCU_INVARIANT(x)
Definition: Assert.h:201
SH::TagList::iterator
std::set< std::string >::const_iterator iterator
the iterator to use
Definition: TagList.h:96
SH::TagList::m_tags
std::set< std::string > m_tags
the list of tags
Definition: TagList.h:146
SH::TagList::end
iterator end() const
the end iterator to use
Definition: TagList.cxx:107
RCU_CHANGE_INVARIANT
#define RCU_CHANGE_INVARIANT(x)
Definition: Assert.h:231
RCU_THROW_MSG
#define RCU_THROW_MSG(message)
Definition: PrintMsg.h:58
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:24
python.PyAthena.obj
obj
Definition: PyAthena.py:135
RCU_READ_INVARIANT
#define RCU_READ_INVARIANT(x)
Definition: Assert.h:229
RCU_NEW_INVARIANT
#define RCU_NEW_INVARIANT(x)
Definition: Assert.h:233