MercuryDPM  Alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BaseObject Class Referenceabstract

It is an abstract base class due to the purely virtual functions declared below. Even if the function is purely virtual, it does not imply that it cannot have a definition. Abstract classes are useful to define a interface. More...

#include <BaseObject.h>

+ Inheritance diagram for BaseObject:

Public Member Functions

 BaseObject ()
 Default constructor. More...
 
 BaseObject (const BaseObject &p)
 Copy constructor, copies all the objects BaseObject contains. More...
 
virtual ~BaseObject ()
 virtual destructor More...
 
virtual void read (std::istream &is)=0
 A purely virtual method with an implementation which reads the index from the stream and assigns it to id_. More...
 
virtual void write (std::ostream &os) const =0
 A purely virtual function which has an implementation which writes the name and the object id_ to the output stream. More...
 
virtual std::string getName () const =0
 A purely virtual function. More...
 
virtual void moveInHandler (const unsigned int index)
 Except that it is virtual, it does the same thing as setIndex() does. More...
 
void setIndex (const unsigned int index)
 Allows one to assign an index to an object in the handler/container. More...
 
void setId (const unsigned int id)
 Assigns a unique identifier to each object in the handler (container) which remains constant even after the object is deleted from the container/handler. More...
 
unsigned int getIndex () const
 Returns the index of the object in the handler. More...
 
unsigned int getId () const
 Returns the unique identifier of any particular object. More...
 

Private Attributes

unsigned int index_
 location in BaseHandler::objects_ More...
 
unsigned int id_
 unique identifier within handler (remains constant even if particle is moved) More...
 

Detailed Description

It is an abstract base class due to the purely virtual functions declared below. Even if the function is purely virtual, it does not imply that it cannot have a definition. Abstract classes are useful to define a interface.

Definition at line 49 of file BaseObject.h.

Constructor & Destructor Documentation

BaseObject::BaseObject ( )

Default constructor.

Initialises the member variables to zero.

Definition at line 55 of file BaseObject.cc.

References DEBUG, id_, index_, and logger.

56 {
57  index_ = 0;
58  id_ = 0;
59  logger(DEBUG,"BaseObject::BaseObject() finished");
60 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
unsigned int index_
location in BaseHandler::objects_
Definition: BaseObject.h:115
unsigned int id_
unique identifier within handler (remains constant even if particle is moved)
Definition: BaseObject.h:120
BaseObject::BaseObject ( const BaseObject p)

Copy constructor, copies all the objects BaseObject contains.

Parameters
[in]p

Definition at line 65 of file BaseObject.cc.

References DEBUG, id_, index_, and logger.

66 {
67  index_ = p.index_;
68  id_ = p.id_;
69  logger(DEBUG,"BaseObject::BaseObject(const BaseObject &p) finished");
70 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
unsigned int index_
location in BaseHandler::objects_
Definition: BaseObject.h:115
unsigned int id_
unique identifier within handler (remains constant even if particle is moved)
Definition: BaseObject.h:120
BaseObject::~BaseObject ( )
virtual

virtual destructor

Definition at line 75 of file BaseObject.cc.

References DEBUG, and logger.

76 {
77  logger(DEBUG,"BaseObject::~BaseBoundary() finished");
78 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")

Member Function Documentation

void BaseObject::moveInHandler ( const unsigned int  index)
virtual

Except that it is virtual, it does the same thing as setIndex() does.

Parameters
[in]index

Definition at line 83 of file BaseObject.cc.

References index_.

84 {
85  index_ = index;
86 }
unsigned int index_
location in BaseHandler::objects_
Definition: BaseObject.h:115
void BaseObject::read ( std::istream &  is)
pure virtual

A purely virtual method with an implementation which reads the index from the stream and assigns it to id_.

Parameters
[in]is

Implemented in Species< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >, IntersectionOfWalls, PeriodicBoundary, TriangulatedWall, InfiniteWall, InsertionBoundary, InfiniteWallWithHole, AxisymmetricIntersectionOfWalls, SphericalWall, BaseParticle, AngledPeriodicBoundary, BaseInteraction, Coil, RestrictedWall, CircularPeriodicBoundary, HopperInsertionBoundary, Screw, DeletionBoundary, CubeInsertionBoundary, CylindricalWall, BaseInteractable, MindlinRollingTorsionInteraction, BaseWall, BaseBoundary, LiquidMigrationWilletInteraction, MindlinInteraction, HertzianViscoelasticInteraction, LinearPlasticViscoelasticInteraction, ChuteInsertionBoundary, FrictionInteraction, BondedInteraction, IrreversibleAdhesiveInteraction, EmptyFrictionInteraction, LinearViscoelasticInteraction, EmptyAdhesiveInteraction, SlidingFrictionInteraction, HertzianSinterInteraction, SinterInteraction, ChargedBondedInteraction, LiquidBridgeWilletInteraction, ParhamiMcMeekingSinterInteraction, ReversibleAdhesiveInteraction, ParticleSpecies, LiquidFilmParticle, ThermalParticle, MaserBoundary, SinterNormalSpecies, LeesEdwardsBoundary, ShearBoxBoundary, BondedSpecies, EmptyFrictionSpecies, FrictionSpecies, MindlinRollingTorsionSpecies, ChargedBondedSpecies, LiquidBridgeWilletSpecies, LiquidMigrationWilletSpecies, ParhamiMcMeekingSinterSpecies, ReversibleAdhesiveSpecies, MindlinSpecies, SlidingFrictionSpecies, HertzianSinterNormalSpecies, HertzianViscoelasticNormalSpecies, LinearPlasticViscoelasticNormalSpecies, LinearViscoelasticNormalSpecies, and EmptyAdhesiveSpecies.

Definition at line 124 of file BaseObject.cc.

References id_.

Referenced by operator>>(), ParticleSpecies::read(), BaseBoundary::read(), and BaseInteractable::read().

125 {
126  std::string dummy;
127  is >> dummy >> id_;
128 }
unsigned int id_
unique identifier within handler (remains constant even if particle is moved)
Definition: BaseObject.h:120
void BaseObject::setId ( const unsigned int  id)

Assigns a unique identifier to each object in the handler (container) which remains constant even after the object is deleted from the container/handler.

Parameters
[in]id
Todo:
TW: here we should update BaseHandler::nextId_

Definition at line 99 of file BaseObject.cc.

References id_.

Referenced by MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::read().

100 {
101  id_ = id;
103 }
unsigned int id_
unique identifier within handler (remains constant even if particle is moved)
Definition: BaseObject.h:120
void BaseObject::setIndex ( const unsigned int  index)

Allows one to assign an index to an object in the handler/container.

Parameters
[in]index

Definition at line 91 of file BaseObject.cc.

References index_.

Referenced by MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::read().

92 {
93  index_ = index;
94 }
unsigned int index_
location in BaseHandler::objects_
Definition: BaseObject.h:115
void BaseObject::write ( std::ostream &  os) const
pure virtual

A purely virtual function which has an implementation which writes the name and the object id_ to the output stream.

Parameters
[in]os

Implemented in Species< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >, IntersectionOfWalls, PeriodicBoundary, InfiniteWall, TriangulatedWall, InfiniteWallWithHole, InsertionBoundary, BaseParticle, AxisymmetricIntersectionOfWalls, SphericalWall, AngledPeriodicBoundary, Coil, RestrictedWall, HopperInsertionBoundary, CircularPeriodicBoundary, BaseInteraction, DeletionBoundary, Screw, CubeInsertionBoundary, CylindricalWall, BaseInteractable, ChuteInsertionBoundary, BaseBoundary, MindlinRollingTorsionInteraction, BaseWall, LiquidMigrationWilletInteraction, MindlinInteraction, HertzianViscoelasticInteraction, LinearPlasticViscoelasticInteraction, BondedInteraction, IrreversibleAdhesiveInteraction, FrictionInteraction, EmptyFrictionInteraction, LinearViscoelasticInteraction, EmptyAdhesiveInteraction, SlidingFrictionInteraction, HertzianSinterInteraction, SinterInteraction, ChargedBondedInteraction, LiquidBridgeWilletInteraction, ParhamiMcMeekingSinterInteraction, ReversibleAdhesiveInteraction, ParticleSpecies, MaserBoundary, SinterNormalSpecies, LeesEdwardsBoundary, ShearBoxBoundary, LiquidFilmParticle, ThermalParticle, BondedSpecies, EmptyFrictionSpecies, FrictionSpecies, MindlinRollingTorsionSpecies, ChargedBondedSpecies, LiquidBridgeWilletSpecies, LiquidMigrationWilletSpecies, ParhamiMcMeekingSinterSpecies, ReversibleAdhesiveSpecies, MindlinSpecies, SlidingFrictionSpecies, HertzianSinterNormalSpecies, HertzianViscoelasticNormalSpecies, LinearPlasticViscoelasticNormalSpecies, LinearViscoelasticNormalSpecies, and EmptyAdhesiveSpecies.

Definition at line 133 of file BaseObject.cc.

References getName(), and id_.

Referenced by operator<<(), ParticleSpecies::write(), BaseBoundary::write(), and BaseInteractable::write().

134 {
135  os << getName();
136  os << " id " << id_;
137 }
unsigned int id_
unique identifier within handler (remains constant even if particle is moved)
Definition: BaseObject.h:120
virtual std::string getName() const =0
A purely virtual function.

Member Data Documentation

unsigned int BaseObject::id_
private

unique identifier within handler (remains constant even if particle is moved)

Definition at line 120 of file BaseObject.h.

Referenced by BaseObject(), getId(), read(), setId(), and write().

unsigned int BaseObject::index_
private

location in BaseHandler::objects_

Definition at line 115 of file BaseObject.h.

Referenced by BaseObject(), getIndex(), moveInHandler(), and setIndex().


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