QMCPACK
OhmmsObject Class Referenceabstract

An OhmmsElementBase with extra members to keep track the object/type. More...

+ Inheritance diagram for OhmmsObject:
+ Collaboration diagram for OhmmsObject:

Public Member Functions

 OhmmsObject ()
 default constructor More...
 
 OhmmsObject (const std::string &tname, const std::string &oname)
 contructor More...
 
 ~OhmmsObject () override
 
int id () const
 return the ObjectID which is unique to each object More...
 
void setID (int i)
 overwrite ObjectID More...
 
int elementByteSize () const
 returns the byte size of the object More...
 
void setTypeName (const std::string &tname)
 set the type name More...
 
void setObjName (const std::string &oname)
 set the object name More...
 
const std::string & typeName () const
 return the type name More...
 
const std::string & objName () const
 return the object name More...
 
virtual OhmmsObjectmakeClone () const =0
 
- Public Member Functions inherited from OhmmsElementBase
 OhmmsElementBase (const char *aname="none")
 constructor with a name More...
 
virtual ~OhmmsElementBase ()
 destructor More...
 
const std::string & getName () const
 return the name More...
 
void setName (const std::string &aname)
 set name More...
 
void setIOMode (int imode)
 set iomode More...
 
virtual bool get (std::ostream &) const =0
 write to a std::ostream More...
 
virtual bool put (std::istream &)=0
 read from std::istream More...
 
virtual bool put (xmlNodePtr cur)=0
 read from an xmlNode More...
 
virtual void reset ()=0
 reset member data More...
 
virtual bool add (xmlNodePtr parent)
 add a xmlNode to the children list of parent More...
 
void put (const std::string &s)
 read from string More...
 
virtual void begin_node (std::ostream &os) const
 write the start of a node More...
 
virtual void end_node (std::ostream &os) const
 write the end of a node More...
 

Protected Attributes

std::string TypeName
 the type name of this object More...
 
int ObjectID
 the unique ID of this object More...
 
int ElementByteSize
 the byte size of this object More...
 
- Protected Attributes inherited from OhmmsElementBase
int myIOMode
 the type of IO mode: default is useLIBXML More...
 
std::string myName
 the name of the node, corresponds to the xml tag More...
 

Additional Inherited Members

- Public Types inherited from OhmmsElementBase
enum  { useLIBXML = 0, useLIBXMLPP, usePLAIN }
 enumeration to choose the xml parser More...
 

Detailed Description

An OhmmsElementBase with extra members to keep track the object/type.

Additional data members of OhmmsObject are

  • TypeName: the name of a type, e.g., PositionType
  • ObjectID: an ID for this object assigned by a constructor
  • ElementByteSize: the byte size of an object. A derived class specifies the value.
  • ObjectCounter: static data member. Incremented whenever an OhmmsObject is created.

It is common for class libraries or applications to have a base class that has an object counter for garbage collections and other functions. This base class is not that smart but enables keeping track the list unique for a process and makes it easy to retrieve an object with a name.

Todo:
This class should be integrated into OhmmsElementBase or an equivalent base class.

Definition at line 43 of file OhmmsObject.h.

Constructor & Destructor Documentation

◆ OhmmsObject() [1/2]

default constructor

Assign meaningless object and type names. Not givng a name to an object is OKAY as far as the object is not requested from a pool.

Definition at line 28 of file OhmmsObject.cpp.

28  : OhmmsElementBase("none"), TypeName("none"), ElementByteSize(0)
29 {
30  // #pragma omp critical
31  // {
32  // ObjectID = ObjectCounter;
33  // ObjectCounter++;
34  // }
35 }
int ElementByteSize
the byte size of this object
Definition: OhmmsObject.h:81
std::string TypeName
the type name of this object
Definition: OhmmsObject.h:75
OhmmsElementBase(const char *aname="none")
constructor with a name

◆ OhmmsObject() [2/2]

OhmmsObject ( const std::string &  tname,
const std::string &  oname 
)

contructor

Parameters
tnamethe name of the type
onamethe name of the object Assign a unique ObjectID using the static data member ObjectCounter

Definition at line 42 of file OhmmsObject.cpp.

43  : OhmmsElementBase(oname.c_str()), TypeName(tname.c_str()), ElementByteSize(0)
44 {
45  // #pragma omp critical
46  // {
47  // ObjectID = ObjectCounter;
48  // ObjectCounter++;
49  // }
50 }
int ElementByteSize
the byte size of this object
Definition: OhmmsObject.h:81
std::string TypeName
the type name of this object
Definition: OhmmsObject.h:75
OhmmsElementBase(const char *aname="none")
constructor with a name

◆ ~OhmmsObject()

~OhmmsObject ( )
override

Definition at line 52 of file OhmmsObject.cpp.

52 {}

Member Function Documentation

◆ elementByteSize()

int elementByteSize ( ) const
inline

returns the byte size of the object

Definition at line 57 of file OhmmsObject.h.

References ElementByteSize.

57 { return ElementByteSize; }
int ElementByteSize
the byte size of this object
Definition: OhmmsObject.h:81

◆ id()

int id ( ) const
inline

return the ObjectID which is unique to each object

Definition at line 51 of file OhmmsObject.h.

References ObjectID.

51 { return ObjectID; }
int ObjectID
the unique ID of this object
Definition: OhmmsObject.h:78

◆ makeClone()

◆ objName()

const std::string& objName ( ) const
inline

return the object name

Definition at line 69 of file OhmmsObject.h.

References OhmmsElementBase::myName.

Referenced by AttribListType::add().

69 { return myName; }
std::string myName
the name of the node, corresponds to the xml tag

◆ setID()

void setID ( int  i)
inline

overwrite ObjectID

Definition at line 54 of file OhmmsObject.h.

References ObjectID.

Referenced by AttribListType::add().

54 { ObjectID = i; }
int ObjectID
the unique ID of this object
Definition: OhmmsObject.h:78

◆ setObjName()

void setObjName ( const std::string &  oname)
inline

set the object name

Definition at line 63 of file OhmmsObject.h.

References OhmmsElementBase::myName.

Referenced by ParticleSet::createAttributeList().

63 { myName = oname; }
std::string myName
the name of the node, corresponds to the xml tag

◆ setTypeName()

void setTypeName ( const std::string &  tname)
inline

set the type name

Definition at line 60 of file OhmmsObject.h.

References TypeName.

Referenced by ParticleSet::createAttributeList().

60 { TypeName = tname; }
std::string TypeName
the type name of this object
Definition: OhmmsObject.h:75

◆ typeName()

const std::string& typeName ( ) const
inline

return the type name

Definition at line 66 of file OhmmsObject.h.

References TypeName.

66 { return TypeName; }
std::string TypeName
the type name of this object
Definition: OhmmsObject.h:75

Member Data Documentation

◆ ElementByteSize

int ElementByteSize
protected

the byte size of this object

Definition at line 81 of file OhmmsObject.h.

Referenced by elementByteSize().

◆ ObjectID

int ObjectID
protected

the unique ID of this object

Definition at line 78 of file OhmmsObject.h.

Referenced by id(), and setID().

◆ TypeName

std::string TypeName
protected

the type name of this object

Definition at line 75 of file OhmmsObject.h.

Referenced by setTypeName(), and typeName().


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