Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91898161
system.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
Fri, Nov 15, 13:55
Size
1 KB
Mime Type
text/x-c++
Expires
Sun, Nov 17, 13:55 (2 d)
Engine
blob
Format
Raw Data
Handle
22343632
Attached To
R9490 Homework_sp4e_Peruzzo_SáezUribe
system.hh
View Options
#ifndef __SYSTEM__HH__
#define __SYSTEM__HH__
/* -------------------------------------------------------------------------- */
#include "my_types.hh"
#include "particle.hh"
#include <memory>
#include <vector>
/* -------------------------------------------------------------------------- */
//! Container for particles
class
System
{
public
:
virtual
~
System
()
=
default
;
// List of particle pointers
using
ParticleList
=
std
::
vector
<
std
::
shared_ptr
<
Particle
>>
;
//! Remove particle from vector
void
removeParticle
(
UInt
particle
){};
//! Get particle for specific id
Particle
&
getParticle
(
UInt
i
);
//! Add a particle to the system
void
addParticle
(
const
std
::
shared_ptr
<
Particle
>&
new_particle
);
//! Get number of particles
UInt
getNbParticles
();
//! Iterator class to erase the unique pointer on Particle
struct
iterator
:
ParticleList
::
iterator
{
iterator
(
const
ParticleList
::
iterator
&
it
)
:
ParticleList
::
iterator
(
it
)
{}
//! Access the underlying particle
Particle
&
operator
*
()
{
return
*
ParticleList
::
iterator
::
operator
*
();
}
};
// Iterators
public
:
auto
begin
()
{
return
iterator
(
list_particles
.
begin
());
}
auto
end
()
{
return
iterator
(
list_particles
.
end
());
}
protected
:
ParticleList
list_particles
;
};
/* -------------------------------------------------------------------------- */
#endif
//__SYSTEM__HH__
Event Timeline
Log In to Comment