ATLAS Offline Software
Public Member Functions | Static Public Attributes | Private Attributes | List of all members
D3PD::ObjectMetadata::Variable Class Reference

Internal class keeping track of a single variable. More...

#include <ObjectMetadata.h>

Collaboration diagram for D3PD::ObjectMetadata::Variable:

Public Member Functions

 Variable ()
 Default constructor. More...
 
const std::string & type () const
 Type name of the variable. More...
 
const std::string & name () const
 Name of the variable without its prefix. More...
 
const std::string & doc () const
 Description of the variable. More...
 
bool primitive () const
 Flag showing whether the variable is a primitive. More...
 
void setType (const std::string &type)
 Set the type name of the variable. More...
 
void setName (const std::string &name)
 Set the name of the variable. More...
 
void setDoc (const std::string &doc)
 Set the description of the variable. More...
 
void setPrimitive (bool primitive)
 Set whether the variable is a primitive. More...
 
std::string toString () const
 Function "serializing" the variable information into a string. More...
 
StatusCode read (const std::string &data)
 Read data from a "serialized" string. More...
 
bool operator== (const Variable &var) const
 Operator checking the equivalence of two variables. More...
 
bool operator< (const Variable &var) const
 Operator needed to use such objects in STL containers. More...
 

Static Public Attributes

static const char *const STRING_SEPARATOR = "$"
 Character separating parts of the variable's metadata. More...
 

Private Attributes

std::string m_type
 Full type name of the variable. More...
 
std::string m_name
 Name of the variable without its prefix. More...
 
std::string m_doc
 Description of the variable. More...
 
bool m_primitive
 Flag showing whether the variable is a primitive. More...
 

Detailed Description

Internal class keeping track of a single variable.

   This class is used internally by the class to keep all the
   important properties of a D3PD variable. It is mainly used
   by the D3PDReader project to store and retrieve information
   about the D3PDObject-s that produced a D3PD.
Author
Attila Krasznahorkay Attil.nosp@m.a.Kr.nosp@m.aszna.nosp@m.hork.nosp@m.ay@ce.nosp@m.rn.c.nosp@m.h

Definition at line 131 of file ObjectMetadata.h.

Constructor & Destructor Documentation

◆ Variable()

D3PD::ObjectMetadata::Variable::Variable ( )

Default constructor.

Definition at line 422 of file ObjectMetadata.cxx.

423  : m_type( "" ), m_name( "" ), m_doc( "" ), m_primitive( true ) {
424 
425  }

Member Function Documentation

◆ doc()

const std::string & D3PD::ObjectMetadata::Variable::doc ( ) const

Description of the variable.

Definition at line 437 of file ObjectMetadata.cxx.

437  {
438 
439  return m_doc;
440  }

◆ name()

const std::string & D3PD::ObjectMetadata::Variable::name ( ) const

Name of the variable without its prefix.

Definition at line 432 of file ObjectMetadata.cxx.

432  {
433 
434  return m_name;
435  }

◆ operator<()

bool D3PD::ObjectMetadata::Variable::operator< ( const Variable var) const

Operator needed to use such objects in STL containers.

Definition at line 568 of file ObjectMetadata.cxx.

568  {
569 
570  if( name() != var.name() ) {
571  return ( name() < var.name() );
572  } else {
573  return ( type() < var.type() );
574  }
575  }

◆ operator==()

bool D3PD::ObjectMetadata::Variable::operator== ( const Variable var) const

Operator checking the equivalence of two variables.

Definition at line 562 of file ObjectMetadata.cxx.

562  {
563 
564  return ( ( name() == var.name() ) &&
565  ( type() == var.type() ) );
566  }

◆ primitive()

bool D3PD::ObjectMetadata::Variable::primitive ( ) const

Flag showing whether the variable is a primitive.

Definition at line 442 of file ObjectMetadata.cxx.

442  {
443 
444  return m_primitive;
445  }

◆ read()

StatusCode D3PD::ObjectMetadata::Variable::read ( const std::string &  data)

Read data from a "serialized" string.

This function can be used to read in information from a serialized form.

Note that the function is meant to reset all stored properties of the object. (Unlike the function in D3PD::ObjectMetadata!) This is just because merging doesn't make sense for this class.

Parameters
dataThe string that should be decoded
Returns
StatusCode::SUCCESS if the operation was successful, StatusCode::FAILURE otherwise

Definition at line 495 of file ObjectMetadata.cxx.

495  {
496 
497  //
498  // Tokenize the string using Boost:
499  //
500  boost::char_separator< char > separator( STRING_SEPARATOR, "",
501  boost::keep_empty_tokens );
502  boost::tokenizer< boost::char_separator< char > > tokens( data,
503  separator );
504  boost::tokenizer< boost::char_separator< char > >::const_iterator itr = tokens.begin();
505 
506  // Check that we didn't reach the last token yet:
507  if( itr == tokens.end() ) {
508  REPORT_MESSAGE_WITH_CONTEXT( MSG::FATAL, "ObjectMetadata::Variable" )
509  << "The received data can not be parsed successfully: "
510  << data;
511  return StatusCode::FAILURE;
512  }
513 
514  // Extract the name of the variable:
515  m_name = *itr; ++itr;
516 
517  // Check that we didn't reach the last token yet:
518  if( itr == tokens.end() ) {
519  REPORT_MESSAGE_WITH_CONTEXT( MSG::FATAL, "ObjectMetadata::Variable" )
520  << "The received data can not be parsed successfully: "
521  << data;
522  return StatusCode::FAILURE;
523  }
524 
525  // Extract the type of the variable:
526  m_type = *itr; ++itr;
527 
528  // Check that we didn't reach the last token yet:
529  if( itr == tokens.end() ) {
530  REPORT_MESSAGE_WITH_CONTEXT( MSG::FATAL, "ObjectMetadata::Variable" )
531  << "The received data can not be parsed successfully: "
532  << data;
533  return StatusCode::FAILURE;
534  }
535 
536  // Extract the documentation string of the variable:
537  m_doc = *itr; ++itr;
538 
539  // Check that we didn't reach the last token yet:
540  if( itr == tokens.end() ) {
541  REPORT_MESSAGE_WITH_CONTEXT( MSG::FATAL, "ObjectMetadata::Variable" )
542  << "The received data can not be parsed successfully: "
543  << data;
544  return StatusCode::FAILURE;
545  }
546 
547  // Extract the information of whether this variable is a primitive or not:
548  if( *itr == "0" ) {
549  m_primitive = false;
550  } else if( *itr == "1" ) {
551  m_primitive = true;
552  } else {
553  REPORT_MESSAGE_WITH_CONTEXT( MSG::FATAL, "ObjectMetadata::Variable" )
554  << "The received data can not be parsed successfully: "
555  << data;
556  return StatusCode::FAILURE;
557  }
558 
559  return StatusCode::SUCCESS;
560  }

◆ setDoc()

void D3PD::ObjectMetadata::Variable::setDoc ( const std::string &  doc)

Set the description of the variable.

Definition at line 459 of file ObjectMetadata.cxx.

459  {
460 
461  m_doc = doc;
462  return;
463  }

◆ setName()

void D3PD::ObjectMetadata::Variable::setName ( const std::string &  name)

Set the name of the variable.

Definition at line 453 of file ObjectMetadata.cxx.

453  {
454 
455  m_name = name;
456  return;
457  }

◆ setPrimitive()

void D3PD::ObjectMetadata::Variable::setPrimitive ( bool  primitive)

Set whether the variable is a primitive.

Definition at line 465 of file ObjectMetadata.cxx.

465  {
466 
468  return;
469  }

◆ setType()

void D3PD::ObjectMetadata::Variable::setType ( const std::string &  type)

Set the type name of the variable.

Definition at line 447 of file ObjectMetadata.cxx.

447  {
448 
449  m_type = type;
450  return;
451  }

◆ toString()

std::string D3PD::ObjectMetadata::Variable::toString ( ) const

Function "serializing" the variable information into a string.

This function translates the contents of the variable into a single string.

The different parts of the configuration string are separated by "$" character. (So variable names and variable descriptions can't have this character in them.)

Returns
The configuration of this variable "serialized" into a string

Definition at line 479 of file ObjectMetadata.cxx.

479  {
480 
482  m_doc + STRING_SEPARATOR + ( m_primitive ? "1" : "0" );
483  }

◆ type()

const std::string & D3PD::ObjectMetadata::Variable::type ( ) const

Type name of the variable.

Definition at line 427 of file ObjectMetadata.cxx.

427  {
428 
429  return m_type;
430  }

Member Data Documentation

◆ m_doc

std::string D3PD::ObjectMetadata::Variable::m_doc
private

Description of the variable.

Definition at line 164 of file ObjectMetadata.h.

◆ m_name

std::string D3PD::ObjectMetadata::Variable::m_name
private

Name of the variable without its prefix.

Definition at line 163 of file ObjectMetadata.h.

◆ m_primitive

bool D3PD::ObjectMetadata::Variable::m_primitive
private

Flag showing whether the variable is a primitive.

Definition at line 165 of file ObjectMetadata.h.

◆ m_type

std::string D3PD::ObjectMetadata::Variable::m_type
private

Full type name of the variable.

Definition at line 162 of file ObjectMetadata.h.

◆ STRING_SEPARATOR

const char *const D3PD::ObjectMetadata::Variable::STRING_SEPARATOR = "$"
static

Character separating parts of the variable's metadata.

Definition at line 160 of file ObjectMetadata.h.


The documentation for this class was generated from the following files:
beamspotnt.var
var
Definition: bin/beamspotnt.py:1394
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
D3PD::ObjectMetadata::Variable::m_type
std::string m_type
Full type name of the variable.
Definition: ObjectMetadata.h:162
D3PD::ObjectMetadata::Variable::primitive
bool primitive() const
Flag showing whether the variable is a primitive.
Definition: ObjectMetadata.cxx:442
D3PD::ObjectMetadata::Variable::type
const std::string & type() const
Type name of the variable.
Definition: ObjectMetadata.cxx:427
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
beamspotman.tokens
tokens
Definition: beamspotman.py:1284
D3PD::ObjectMetadata::Variable::STRING_SEPARATOR
static const char *const STRING_SEPARATOR
Character separating parts of the variable's metadata.
Definition: ObjectMetadata.h:160
REPORT_MESSAGE_WITH_CONTEXT
#define REPORT_MESSAGE_WITH_CONTEXT(LVL, CONTEXT_NAME)
Report a message, with an explicitly specified context name.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:345
D3PD::ObjectMetadata::Variable::name
const std::string & name() const
Name of the variable without its prefix.
Definition: ObjectMetadata.cxx:432
D3PD::ObjectMetadata::Variable::m_primitive
bool m_primitive
Flag showing whether the variable is a primitive.
Definition: ObjectMetadata.h:165
D3PD::ObjectMetadata::Variable::m_doc
std::string m_doc
Description of the variable.
Definition: ObjectMetadata.h:164
D3PD::ObjectMetadata::Variable::m_name
std::string m_name
Name of the variable without its prefix.
Definition: ObjectMetadata.h:163
D3PD::ObjectMetadata::Variable::doc
const std::string & doc() const
Description of the variable.
Definition: ObjectMetadata.cxx:437