Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91235606
particle.hh
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Nov 9, 05:53
Size
1 KB
Mime Type
text/x-c++
Expires
Mon, Nov 11, 05:53 (2 d)
Engine
blob
Format
Raw Data
Handle
22226548
Attached To
R9484 sp4e-homework-lars-bertil
particle.hh
View Options
#ifndef __PARTICLE__HH__
#define __PARTICLE__HH__
/* -------------------------------------------------------------------------- */
#include "vector.hh"
/* -------------------------------------------------------------------------- */
//! Particle base class
class
Particle
{
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public
:
//! Default destructor (virtual because of virtual functions in this class)
virtual
~
Particle
()
=
default
;
// Accessors
public
:
//! Get mass
Real
&
getMass
()
{
return
mass
;
}
//! Get position
Vector
&
getPosition
()
{
return
position
;
}
//! Get force
Vector
&
getForce
()
{
return
force
;
}
//! Get velocity
Vector
&
getVelocity
()
{
return
velocity
;
}
//! Set position
void
setPosition
(
Vector
&
pos
)
{
position
=
pos
;
}
// I/O functions
public
:
/// function to print the content of the class
virtual
void
printself
(
std
::
ostream
&
stream
)
const
;
/// function to initilize values from input files
virtual
void
initself
(
std
::
istream
&
sstr
);
// Members
protected
:
Real
mass
;
Vector
position
,
force
,
velocity
;
};
/* -------------------------------------------------------------------------- */
/* Inline functions */
/* -------------------------------------------------------------------------- */
inline
std
::
istream
&
operator
>>
(
std
::
istream
&
sstr
,
Particle
&
_this
)
{
_this
.
initself
(
sstr
);
return
sstr
;
}
/* -------------------------------------------------------------------------- */
inline
std
::
ostream
&
operator
<<
(
std
::
ostream
&
sstr
,
Particle
&
_this
)
{
_this
.
printself
(
sstr
);
return
sstr
;
}
/* -------------------------------------------------------------------------- */
#endif
//__PARTICLE__HH__
Event Timeline
Log In to Comment