ra4_draw  4bd0201e3d922d42bd545d4b045ed44db33454a4
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Variable Class Reference

A variable to be accessible in Baby classes. More...

#include <generate_baby.hpp>

Public Member Functions

 Variable (const std::string &name)
 Standard constructor. More...
 
const std::string & Name () const
 Get variable name. More...
 
std::string & Name ()
 Get variable name. More...
 
std::string Type () const
 Get one type for variable across all Baby classes. More...
 
std::string Type (const std::string &baby_type) const
 Get type of variable for a derived Baby class. More...
 
std::string DecoratedType () const
 Get type with "std::" and "*" if needed. More...
 
std::string DecoratedType (const std::string &baby_type) const
 Get type with "std::" and "*" if needed. More...
 
bool HasEntry (const std::string &baby_type) const
 Check if a derived Baby class has this variable. More...
 
void SetEntry (const std::string &baby_type, const std::string &type)
 Set the type of this variable for use in a derived Baby class. More...
 
bool ImplementInBase () const
 Check if variable can be implemented directly in Baby. More...
 
bool VirtualInBase () const
 Check if variable should have pure virtual method in Baby. More...
 
bool ImplementIn (const std::string &baby_type) const
 Check if variable needs accessor implemented in a derived Baby class. More...
 
bool NotInBase () const
 Check if variable is completely absent in base Baby. More...
 
bool EverythingIn (const std::string &baby_type) const
 Check if variable needs declaration and definition in a derived class. More...
 
bool operator< (const Variable &other) const
 Comparison operator allows storing Variable in set. More...
 

Private Member Functions

std::set< std::string > GetTypeSet () const
 Get all types (int, float, etc.) used across derived Baby classes. More...
 

Private Attributes

std::string name_
 Name of variable (e.g., ht, met, etc.) More...
 
std::map< std::string, std::string > type_map_
 Map from Baby type (basic, full, etc.) to variabl type (int, float, etc.) More...
 

Detailed Description

A variable to be accessible in Baby classes.

Stores information about which concrete classes in which to implement the variable.

Used only to generate Baby classes, but not in subsequent analysis code.

Definition at line 14 of file generate_baby.hpp.

Constructor & Destructor Documentation

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

Standard constructor.

Parameters
[in]nameName of variable (e.g., ht, met, etc.)

Definition at line 63 of file generate_baby.cxx.

Member Function Documentation

string Variable::DecoratedType ( ) const

Get type with "std::" and "*" if needed.

Returns
If type is the same in all Baby classes, returns that type with "std::" and "*" added if needed. Otherwise, returns empty string.
See also
Variable::Type()

Definition at line 124 of file generate_baby.cxx.

References Type().

string Variable::DecoratedType ( const std::string &  baby_type) const

Get type with "std::" and "*" if needed.

Parameters
[in]baby_typeName of derived Baby class (e.g., basic, full) for which to get type
Returns
Type of variable as used in the derived Baby class, with "std::" and "*" if needed
See also
Variable::Type(const std::string &baby_type) const

Definition at line 142 of file generate_baby.cxx.

References Type().

bool Variable::EverythingIn ( const std::string &  baby_type) const

Check if variable needs declaration and definition in a derived class.

Parameters
[in]baby_typeSpecifies derived Baby class to check
Returns
True if variable exists in specified derived class, but does not have virtual function in base Baby

Definition at line 247 of file generate_baby.cxx.

References NotInBase(), and Type().

set< string > Variable::GetTypeSet ( ) const
private

Get all types (int, float, etc.) used across derived Baby classes.

May include an empty string if variable is absent from some derived Baby classes

Returns
List of types used in all derived Baby classes

Definition at line 270 of file generate_baby.cxx.

References type_map_.

Referenced by ImplementInBase(), NotInBase(), and VirtualInBase().

bool Variable::HasEntry ( const std::string &  baby_type) const

Check if a derived Baby class has this variable.

Parameters
[in]baby_typeName of derived Baby class (e.g., basic, full) to check
Returns
True if and only if the derived Baby type contains this variable

Definition at line 156 of file generate_baby.cxx.

References type_map_.

Referenced by Type().

bool Variable::ImplementIn ( const std::string &  baby_type) const

Check if variable needs accessor implemented in a derived Baby class.

Parameters
[in]baby_typeType of derived Baby to check
Returns
True if variable is virtual in Baby, and implemented in the specified derived class

Definition at line 213 of file generate_baby.cxx.

References Type(), and VirtualInBase().

bool Variable::ImplementInBase ( ) const

Check if variable can be implemented directly in Baby.

Implementation in Baby requires that the variable be present in all derived Baby classes with the same type

Returns
True if variable accessor can be implemented in Baby

Definition at line 179 of file generate_baby.cxx.

References GetTypeSet().

Referenced by Type().

const std::string & Variable::Name ( ) const

Get variable name.

Returns
Variable name

Definition at line 72 of file generate_baby.cxx.

References name_.

Referenced by GetVariables().

std::string & Variable::Name ( )

Get variable name.

Returns
Variable name

Definition at line 80 of file generate_baby.cxx.

References name_.

bool Variable::NotInBase ( ) const

Check if variable is completely absent in base Baby.

This occus if the variable has different types in different derived Baby classes

Returns
True if variable is only present in derived Baby classes and not in Baby

Definition at line 225 of file generate_baby.cxx.

References GetTypeSet().

Referenced by EverythingIn().

bool Variable::operator< ( const Variable other) const

Comparison operator allows storing Variable in set.

Sorts alphabetically by name

Parameters
[in]otherVariable to compare to
Returns
True if *this is alphabetically before other

Definition at line 259 of file generate_baby.cxx.

References name_.

void Variable::SetEntry ( const std::string &  baby_type,
const std::string &  type 
)

Set the type of this variable for use in a derived Baby class.

Parameters
[in]baby_typeSpecifies the derived Baby class (e.g., basic, full) for which to set variable type
[in]typeVariable type to set (e.g., int, float)

Definition at line 167 of file generate_baby.cxx.

References type_map_.

Referenced by GetVariables().

string Variable::Type ( ) const

Get one type for variable across all Baby classes.

Returns
If type is the same in all derived Baby classes, return that type. Otherwise, returns empty string.
See also
Variable::Type()

Definition at line 91 of file generate_baby.cxx.

References ImplementInBase(), type_map_, and VirtualInBase().

Referenced by DecoratedType(), EverythingIn(), and ImplementIn().

string Variable::Type ( const std::string &  baby_type) const

Get type of variable for a derived Baby class.

Parameters
[in]baby_typeName of derived Baby class (e.g., basic, full) for which to get type
Returns
Type of variable as used in the derived Baby class
See also
Variable::DecoratedType(const std::string &baby_type) const

Definition at line 109 of file generate_baby.cxx.

References HasEntry(), and type_map_.

bool Variable::VirtualInBase ( ) const

Check if variable should have pure virtual method in Baby.

Pure virtual accessor is needed if and only if the variable has exactly one type across all derived Baby classes, but does is only present in a subset of the classes.

Returns
True if variable should have virtual accessor in Baby

Definition at line 192 of file generate_baby.cxx.

References GetTypeSet().

Referenced by ImplementIn(), and Type().

Member Data Documentation

std::string Variable::name_
private

Name of variable (e.g., ht, met, etc.)

Definition at line 41 of file generate_baby.hpp.

Referenced by Name(), and operator<().

std::map<std::string, std::string> Variable::type_map_
private

Map from Baby type (basic, full, etc.) to variabl type (int, float, etc.)

Definition at line 42 of file generate_baby.hpp.

Referenced by GetTypeSet(), HasEntry(), SetEntry(), and Type().


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