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 (const std::string &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 422 of file ObjectMetadata.cxx.

423 : m_type( "" ), m_name( "" ), m_doc( "" ), m_primitive( true ) {
424
425 }
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 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 }
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 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 }
#define REPORT_MESSAGE_WITH_CONTEXT(LVL, CONTEXT_NAME)
Report a message, with an explicitly specified context name.
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
static const char *const STRING_SEPARATOR
Character separating parts of the variable's metadata.

◆ 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 }
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 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 }
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 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: