6#ifndef HEPMC3_ATTRIBUTE_H
7#define HEPMC3_ATTRIBUTE_H
29#include "HepMC3/GenParticle_fwd.h"
30#include "HepMC3/GenVertex_fwd.h"
120 return std::const_pointer_cast<GenParticle>(
m_particle);
130 return std::const_pointer_cast<GenVertex>(
m_vertex);
169 m_val = atoi( att.c_str() );
175 att = std::to_string(
m_val);
210 m_val = atol( att.c_str() );
216 att = std::to_string(
m_val);
253 m_val = atof( att.c_str() );
259 std::ostringstream oss;
260 oss << std::setprecision(std::numeric_limits<double>::digits10)
298 m_val = float(atof( att.c_str() ));
304 std::ostringstream oss;
305 oss << std::setprecision(std::numeric_limits<float>::digits10)
401 att = std::to_string(
m_val);
436 m_val = atoll( att.c_str() );
442 att = std::to_string(
m_val);
479 m_val = strtold( att.c_str(),NULL);
485 std::ostringstream oss;
486 oss << std::setprecision(std::numeric_limits<long double>::digits10)
526 m_val = strtoul(att.c_str(), NULL, 0);
532 att = std::to_string(
m_val);
569 m_val = strtoul(att.c_str(), NULL, 0);
575 att = std::to_string(
m_val);
611 m_val = strtoull(att.c_str(), NULL, 0);
617 att = std::to_string(
m_val);
651 if (att.size()!=1)
return false;
652 if(att==std::string(
"1")) {
m_val =
true;
return true;}
653 if(att==std::string(
"0")) {
m_val =
false;
return true;}
659 att = std::to_string(
m_val);
Forward declaration of GenParticle.
virtual ~Attribute()
Virtual destructor.
virtual bool from_string(const string &att)=0
Fill class content from string.
bool is_parsed() const
Check if this attribute is parsed.
ConstGenVertexPtr vertex() const
const GenEvent * event() const
Attribute()
Default constructor.
ConstGenParticlePtr particle() const
string m_string
Raw (unparsed) string.
GenParticlePtr particle()
void set_unparsed_string(const string &st)
Set unparsed string.
GenVertexPtr m_vertex
Vertex to which assigned.
virtual bool to_string(string &att) const =0
Fill string from class content.
Attribute(const string &st)
Protected constructor that allows to set string.
GenParticlePtr m_particle
controlling GenEvent object.
virtual bool init(const GenRunInfo &)
Optionally initialize the attribute after from_string.
const string & unparsed_string() const
Get unparsed string.
virtual bool init()
Optionally initialize the attribute after from_string.
void set_is_parsed(bool flag)
Set is_parsed flag.
bool m_is_parsed
Is this attribute parsed?
Attribute that holds an Booleger implemented as an int.
bool to_string(string &att) const
Implementation of Attribute::to_string.
BoolAttribute(bool val)
Constructor initializing attribute value.
BoolAttribute()
Default constructor.
bool from_string(const string &att)
Implementation of Attribute::from_string.
bool value() const
get the value associated to this Attribute.
bool m_val
Attribute value.
void set_value(const bool &i)
set the value associated to this Attribute.
Attribute that holds an Chareger implemented as an int.
CharAttribute(char val)
Constructor initializing attribute value.
bool to_string(string &att) const
Implementation of Attribute::to_string.
CharAttribute()
Default constructor.
bool from_string(const string &att)
Implementation of Attribute::from_string.
void set_value(const char &i)
set the value associated to this Attribute.
char value() const
get the value associated to this Attribute.
char m_val
Attribute value.
Attribute that holds a real number as a double.
bool to_string(string &att) const
Implementation of Attribute::to_string.
double m_val
Attribute value.
void set_value(const double &d)
set the value associated to this Attribute.
double value() const
get the value associated to this Attribute.
bool from_string(const string &att)
Implementation of Attribute::from_string.
DoubleAttribute()
Default constructor.
DoubleAttribute(double val)
Constructor initializing attribute value.
Attribute that holds a real number as a float.
bool to_string(string &att) const
Implementation of Attribute::to_string.
float m_val
Attribute value.
bool from_string(const string &att)
Implementation of Attribute::from_string.
FloatAttribute()
Default constructor.
FloatAttribute(float val)
Constructor initializing attribute value.
void set_value(const float &f)
set the value associated to this Attribute.
float value() const
get the value associated to this Attribute.
Stores event-related information.
Stores run-related information.
Attribute that holds an Integer implemented as an int.
bool to_string(string &att) const
Implementation of Attribute::to_string.
int m_val
Attribute value.
void set_value(const int &i)
set the value associated to this Attribute.
bool from_string(const string &att)
Implementation of Attribute::from_string.
IntAttribute()
Default constructor.
int value() const
get the value associated to this Attribute.
IntAttribute(int val)
Constructor initializing attribute value.
Attribute that holds an Integer implemented as an int.
bool to_string(string &att) const
Implementation of Attribute::to_string.
long m_val
Attribute value.
LongAttribute(long val)
Constructor initializing attribute value.
void set_value(const long &l)
set the value associated to this Attribute.
bool from_string(const string &att)
Implementation of Attribute::from_string.
long value() const
get the value associated to this Attribute.
LongAttribute()
Default constructor.
Attribute that holds a real number as a double.
long double m_val
Attribute value.
bool to_string(string &att) const
Implementation of Attribute::to_string.
LongDoubleAttribute()
Default constructor.
bool from_string(const string &att)
Implementation of Attribute::from_string.
LongDoubleAttribute(long double val)
Constructor initializing attribute value.
void set_value(const long double &d)
set the value associated to this Attribute.
long double value() const
get the value associated to this Attribute.
Attribute that holds an Integer implemented as an int.
long long value() const
get the value associated to this Attribute.
bool to_string(string &att) const
Implementation of Attribute::to_string.
bool from_string(const string &att)
Implementation of Attribute::from_string.
void set_value(const long long &l)
set the value associated to this Attribute.
LongLongAttribute(long long val)
Constructor initializing attribute value.
LongLongAttribute()
Default constructor.
long long m_val
Attribute value.
Attribute that holds a string.
bool to_string(string &att) const
Implementation of Attribute::to_string.
StringAttribute()
Default constructor - empty string.
string value() const
get the value associated to this Attribute.
bool from_string(const string &att)
Implementation of Attribute::from_string.
void set_value(const string &s)
set the value associated to this Attribute.
StringAttribute(const string &st)
String-based constructor.
Attribute that holds an unsigned int.
bool to_string(string &att) const
Implementation of Attribute::to_string.
void set_value(const unsigned int &i)
set the value associated to this Attribute.
unsigned int value() const
get the value associated to this Attribute.
bool from_string(const string &att)
Implementation of Attribute::from_string.
UIntAttribute(unsigned int val)
Constructor initializing attribute value.
unsigned int m_val
Attribute value.
UIntAttribute()
Default constructor.
Attribute that holds an unsigned long.
bool to_string(string &att) const
Implementation of Attribute::to_string.
ULongAttribute()
Default constructor.
ULongAttribute(unsigned long val)
Constructor initializing attribute value.
bool from_string(const string &att)
Implementation of Attribute::from_string.
void set_value(const unsigned long &i)
set the value associated to this Attribute.
unsigned long m_val
Attribute value.
unsigned long value() const
get the value associated to this Attribute.
Attribute that holds an unsigned long long.
bool to_string(string &att) const
Implementation of Attribute::to_string.
bool from_string(const string &att)
Implementation of Attribute::from_string.
unsigned long long m_val
Attribute value.
unsigned long long value() const
get the value associated to this Attribute.
ULongLongAttribute()
Default constructor.
void set_value(const unsigned long long &i)
set the value associated to this Attribute.
ULongLongAttribute(unsigned long long val)
Constructor initializing attribute value.