ATLAS Offline Software
Loading...
Searching...
No Matches
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.
const std::string & type () const
 Type name of the variable.
const std::string & name () const
 Name of the variable without its prefix.
const std::string & doc () const
 Description of the variable.
bool primitive () const
 Flag showing whether the variable is a primitive.
void setType (const std::string &type)
 Set the type name of the variable.
void setName (const std::string &name)
 Set the name of the variable.
void setDoc (std::string_view doc)
 Set the description of the variable.
void setPrimitive (bool primitive)
 Set whether the variable is a primitive.
std::string toString () const
 Function "serializing" the variable information into a string.
StatusCode read (const std::string &data)
 Read data from a "serialized" string.
bool operator== (const Variable &var) const
 Operator checking the equivalence of two variables.
bool operator< (const Variable &var) const
 Operator needed to use such objects in STL containers.

Static Public Attributes

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

Private Attributes

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

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 423 of file ObjectMetadata.cxx.

424 : m_type( "" ), m_name( "" ), m_doc( "" ), m_primitive( true ) {
425
426 }
bool m_primitive
Flag showing whether the variable is a primitive.
std::string m_type
Full type name of the variable.
std::string m_name
Name of the variable without its prefix.
std::string m_doc
Description of the variable.

Member Function Documentation

◆ doc()

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

Description of the variable.

Definition at line 438 of file ObjectMetadata.cxx.

438 {
439
440 return m_doc;
441 }

◆ name()

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

Name of the variable without its prefix.

Definition at line 433 of file ObjectMetadata.cxx.

433 {
434
435 return m_name;
436 }

◆ operator<()

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

Operator needed to use such objects in STL containers.

Definition at line 569 of file ObjectMetadata.cxx.

569 {
570
571 if( name() != var.name() ) {
572 return ( name() < var.name() );
573 } else {
574 return ( type() < var.type() );
575 }
576 }
const std::string & type() const
Type name of the variable.
const std::string & name() const
Name of the variable without its prefix.

◆ operator==()

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

Operator checking the equivalence of two variables.

Definition at line 563 of file ObjectMetadata.cxx.

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

◆ primitive()

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

Flag showing whether the variable is a primitive.

Definition at line 443 of file ObjectMetadata.cxx.

443 {
444
445 return m_primitive;
446 }

◆ 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 496 of file ObjectMetadata.cxx.

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

◆ setDoc()

void D3PD::ObjectMetadata::Variable::setDoc ( std::string_view doc)

Set the description of the variable.

Definition at line 460 of file ObjectMetadata.cxx.

460 {
461
462 m_doc.assign(doc);
463 return;
464 }
const std::string & doc() const
Description of the variable.

◆ setName()

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

Set the name of the variable.

Definition at line 454 of file ObjectMetadata.cxx.

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

◆ setPrimitive()

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

Set whether the variable is a primitive.

Definition at line 466 of file ObjectMetadata.cxx.

466 {
467
469 return;
470 }
bool primitive() const
Flag showing whether the variable is a primitive.

◆ setType()

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

Set the type name of the variable.

Definition at line 448 of file ObjectMetadata.cxx.

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

◆ 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 480 of file ObjectMetadata.cxx.

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

◆ type()

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

Type name of the variable.

Definition at line 428 of file ObjectMetadata.cxx.

428 {
429
430 return m_type;
431 }

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: