MercuryDPM  Beta
 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 51 of file BaseObject.cc.

References id_, and index_.

52 {
53  index_ = 0;
54  id_ = 0;
55 #ifdef DEBUG_CONSTRUCTOR
56  std::cout<<"BaseObject::BaseObject() finished"<<std::endl;
57 #endif
58 }
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 63 of file BaseObject.cc.

References id_, and index_.

64 {
65  index_ = p.index_;
66  id_ = p.id_;
67 #ifdef DEBUG_CONSTRUCTOR
68  std::cout<<"BaseObject::BaseObject(const BaseObject &p) finished"<<std::endl;
69 #endif
70 }
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 74 of file BaseObject.cc.

75 {
76 #ifdef DEBUG_DESTRUCTOR
77  std::cout << "BaseObject::~BaseBoundary() finished"<<std::endl;
78 #endif
79 }

Member Function Documentation

unsigned int BaseObject::getId ( ) const

Returns the unique identifier of any particular object.

Returns
id_

Definition at line 113 of file BaseObject.cc.

References id_.

Referenced by DPMBase::computeInternalForces(), DPMBase::getInfo(), HGrid::insertParticleToHgrid(), ParticleHandler::readObject(), BaseParticle::setIndSpecies(), MixedSpecies< NormalForceSpecies, FrictionForceSpecies, AdhesiveForceSpecies >::write(), BaseInteraction::write(), and BaseParticle::~BaseParticle().

114 {
115  return id_;
116 }
unsigned int id_
unique identifier within handler (remains constant even if particle is moved)
Definition: BaseObject.h:120
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, InfiniteWallWithHole, InfiniteWall, InsertionBoundary, BaseParticle, AngledPeriodicBoundary, Coil, CircularPeriodicBoundary, HopperInsertionBoundary, AxisymmetricIntersectionOfWalls, Screw, DeletionBoundary, CubeInsertionBoundary, CylindricalWall, BaseInteractable, BaseInteraction, BaseBoundary, ChuteInsertionBoundary, FrictionInteraction, IrreversibleAdhesiveInteraction, EmptyFrictionInteraction, LinearViscoelasticInteraction, EmptyAdhesiveInteraction, SlidingFrictionInteraction, LinearPlasticViscoelasticInteraction, BaseWall, LiquidBridgeWilletInteraction, ReversibleAdhesiveInteraction, HertzianViscoelasticInteraction, ParticleSpecies, MaserBoundary, LeesEdwardsBoundary, EmptyFrictionSpecies, FrictionSpecies, LiquidBridgeWilletSpecies, ReversibleAdhesiveSpecies, SlidingFrictionSpecies, HertzianViscoelasticNormalSpecies, LinearPlasticViscoelasticNormalSpecies, LinearViscoelasticNormalSpecies, and EmptyAdhesiveSpecies.

Definition at line 120 of file BaseObject.cc.

References id_.

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

121 {
122  std::string dummy;
123  is >> dummy >> id_;
124 }
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 98 of file BaseObject.cc.

References id_.

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

99 {
100  id_ = id;
102 }
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, InfiniteWallWithHole, InfiniteWall, InsertionBoundary, BaseParticle, Coil, AngledPeriodicBoundary, HopperInsertionBoundary, CircularPeriodicBoundary, DeletionBoundary, Screw, CubeInsertionBoundary, CylindricalWall, AxisymmetricIntersectionOfWalls, BaseInteractable, ChuteInsertionBoundary, BaseInteraction, BaseBoundary, IrreversibleAdhesiveInteraction, FrictionInteraction, EmptyFrictionInteraction, LinearViscoelasticInteraction, BaseWall, EmptyAdhesiveInteraction, SlidingFrictionInteraction, LinearPlasticViscoelasticInteraction, LiquidBridgeWilletInteraction, ReversibleAdhesiveInteraction, HertzianViscoelasticInteraction, ParticleSpecies, MaserBoundary, LeesEdwardsBoundary, EmptyFrictionSpecies, FrictionSpecies, LiquidBridgeWilletSpecies, ReversibleAdhesiveSpecies, SlidingFrictionSpecies, HertzianViscoelasticNormalSpecies, LinearPlasticViscoelasticNormalSpecies, LinearViscoelasticNormalSpecies, and EmptyAdhesiveSpecies.

Definition at line 128 of file BaseObject.cc.

References getName(), and id_.

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

129 {
130  os << getName();
131  os << " id " << id_;
132 }
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: