MARLEY (Model of Argon Reaction Low Energy Yields) v2.0.0
A Monte Carlo event generator for tens-of-MeV neutrino interactions
Loading...
Searching...
No Matches
HepMC3::FloatAttribute Class Reference

Attribute that holds a real number as a float. More...

#include <Attribute.h>

Inheritance diagram for HepMC3::FloatAttribute:
HepMC3::Attribute

Public Member Functions

 FloatAttribute ()
 Default constructor.
 
 FloatAttribute (float val)
 Constructor initializing attribute value.
 
bool from_string (const std::string &att) override
 Implementation of Attribute::from_string.
 
void set_value (const float &f)
 set the value associated to this Attribute.
 
bool to_string (std::string &att) const override
 Implementation of Attribute::to_string.
 
float value () const
 get the value associated to this Attribute.
 
- Public Member Functions inherited from HepMC3::Attribute
 Attribute ()
 Default constructor.
 
virtual ~Attribute ()
 Virtual destructor.
 
const GenEventevent () const
 
virtual bool init ()
 Optionally initialize the attribute after from_string.
 
virtual bool init (const GenRunInfo &)
 Optionally initialize the attribute after from_string.
 
bool is_parsed () const
 Check if this attribute is parsed.
 
GenParticlePtr particle ()
 
ConstGenParticlePtr particle () const
 
const std::string & unparsed_string () const
 Get unparsed string.
 
GenVertexPtr vertex ()
 
ConstGenVertexPtr vertex () const
 

Additional Inherited Members

- Protected Member Functions inherited from HepMC3::Attribute
 Attribute (const std::string &st)
 Protected constructor that allows to set string.
 
void set_is_parsed (bool flag)
 Set is_parsed flag.
 
void set_unparsed_string (const std::string &st)
 Set unparsed string.
 

Detailed Description

Attribute that holds a real number as a float.

Definition at line 292 of file Attribute.h.

Constructor & Destructor Documentation

◆ FloatAttribute() [1/2]

HepMC3::FloatAttribute::FloatAttribute ( )
inline

Default constructor.

Definition at line 296 of file Attribute.h.

296: Attribute(), m_val(0.0) {}
Attribute()
Default constructor.
Definition Attribute.h:51

References HepMC3::Attribute::Attribute().

◆ FloatAttribute() [2/2]

HepMC3::FloatAttribute::FloatAttribute ( float val)
inline

Constructor initializing attribute value.

Definition at line 299 of file Attribute.h.

299: Attribute(), m_val(val) {}

References HepMC3::Attribute::Attribute().

Member Function Documentation

◆ from_string()

bool HepMC3::FloatAttribute::from_string ( const std::string & att)
inlineoverridevirtual

Implementation of Attribute::from_string.

Implements HepMC3::Attribute.

Definition at line 302 of file Attribute.h.

302 {
303 m_val = float(atof( att.c_str() ));
304 set_is_parsed(true);
305 return true;
306 }
void set_is_parsed(bool flag)
Set is_parsed flag.
Definition Attribute.h:134

References HepMC3::Attribute::set_is_parsed().

◆ set_value()

void HepMC3::FloatAttribute::set_value ( const float & f)
inline

set the value associated to this Attribute.

Definition at line 323 of file Attribute.h.

323 {
324 m_val = f;
325 set_is_parsed(true);
326 }

References HepMC3::Attribute::set_is_parsed().

◆ to_string()

bool HepMC3::FloatAttribute::to_string ( std::string & att) const
inlineoverridevirtual

Implementation of Attribute::to_string.

Implements HepMC3::Attribute.

Definition at line 309 of file Attribute.h.

309 {
310 std::ostringstream oss;
311 oss << std::setprecision(std::numeric_limits<float>::digits10)
312 << m_val;
313 att = oss.str();
314 return true;
315 }

◆ value()

float HepMC3::FloatAttribute::value ( ) const
inline

get the value associated to this Attribute.

Definition at line 318 of file Attribute.h.

318 {
319 return m_val;
320 }

The documentation for this class was generated from the following file: