#include <BCP_message.hpp>
Collaboration diagram for BCP_proc_array:
Public Member Functions | |
Constructor and destructor | |
BCP_proc_array () | |
The default constructor creates an empty process array. | |
~BCP_proc_array () | |
The destructor deletes all data members (purges _procs ). | |
Query methods | |
bool | is_free_proc (const int index) |
Determine if the process indexed by the argument is free or not. | |
int | index_of_proc (const BCP_proc_id *proc) |
Return the index of the process given by its process id in the vector of all processes. | |
BCP_vec< BCP_proc_id * > & | procs () |
Return the vector of all processes. | |
const BCP_vec< BCP_proc_id * > & | procs () const |
Return the vector of all processes (const version). | |
const BCP_proc_id * | process (const int i) |
Return a const pointer to the i-th process. | |
int | size () const |
Return the total number of processes. | |
int | free_num () const |
Return the number of free processes. | |
int | busy_num () const |
Return the number of busy (not free) processes. | |
BCP_proc_id * | get_free_proc () |
Get the process id of a free process. | |
Modifying methods | |
void | clear () |
Purge all process ids from the process array. | |
void | add_procs (BCP_vec< BCP_proc_id * >::const_iterator first, BCP_vec< BCP_proc_id * >::const_iterator last) |
Append the processes in [first,last) to the end of the vector of all processes and mark them as free. | |
void | delete_proc (const int index) |
Delete the process indexed by the argument from the vector of all processes (and also from the vector of free processes if applicable). | |
void | set_proc_free (BCP_proc_id *proc) |
Append the process to the end of the vector of free processes. | |
Private Member Functions | |
Disabled methods | |
BCP_proc_array (const BCP_proc_array &) | |
The default constructor is declared but not defined to disable it. | |
BCP_proc_array & | operator= (const BCP_proc_array &) |
The assignment operator is declared but not defined to disable it. | |
Private Attributes | |
Data members | |
BCP_vec< BCP_proc_id * > | _procs |
Vector of all processes. | |
BCP_vec< BCP_proc_id * > | _free_procs |
Vector of free processes (subset of all processes). |
Definition at line 61 of file BCP_message.hpp.
BCP_proc_array::BCP_proc_array | ( | const BCP_proc_array & | ) | [private] |
The default constructor is declared but not defined to disable it.
BCP_proc_array::BCP_proc_array | ( | ) | [inline] |
The default constructor creates an empty process array.
Definition at line 82 of file BCP_message.hpp.
BCP_proc_array::~BCP_proc_array | ( | ) | [inline] |
The destructor deletes all data members (purges _procs
).
Definition at line 84 of file BCP_message.hpp.
References _procs, and purge_ptr_vector().
BCP_proc_array& BCP_proc_array::operator= | ( | const BCP_proc_array & | ) | [private] |
The assignment operator is declared but not defined to disable it.
bool BCP_proc_array::is_free_proc | ( | const int | index | ) | [inline] |
Determine if the process indexed by the argument is free or not.
Definition at line 92 of file BCP_message.hpp.
References _free_procs, _procs, and BCP_vec< T >::size().
int BCP_proc_array::index_of_proc | ( | const BCP_proc_id * | proc | ) | [inline] |
Return the index of the process given by its process id in the vector of all processes.
Definition at line 102 of file BCP_message.hpp.
References _procs, and BCP_vec< T >::size().
BCP_vec<BCP_proc_id*>& BCP_proc_array::procs | ( | ) | [inline] |
Return the vector of all processes.
Definition at line 110 of file BCP_message.hpp.
References _procs.
const BCP_vec<BCP_proc_id*>& BCP_proc_array::procs | ( | ) | const [inline] |
Return the vector of all processes (const version).
Definition at line 112 of file BCP_message.hpp.
References _procs.
const BCP_proc_id* BCP_proc_array::process | ( | const int | i | ) | [inline] |
Return a const pointer to the i-th process.
Definition at line 114 of file BCP_message.hpp.
References _procs.
int BCP_proc_array::size | ( | ) | const [inline] |
Return the total number of processes.
Definition at line 116 of file BCP_message.hpp.
References _procs, and BCP_vec< T >::size().
int BCP_proc_array::free_num | ( | ) | const [inline] |
Return the number of free processes.
Definition at line 118 of file BCP_message.hpp.
References _free_procs, and BCP_vec< T >::size().
int BCP_proc_array::busy_num | ( | ) | const [inline] |
Return the number of busy (not free) processes.
Definition at line 120 of file BCP_message.hpp.
References _free_procs, _procs, and BCP_vec< T >::size().
BCP_proc_id* BCP_proc_array::get_free_proc | ( | ) | [inline] |
Get the process id of a free process.
Return 0 if there are none.
Definition at line 122 of file BCP_message.hpp.
References _free_procs, BCP_vec< T >::back(), BCP_vec< T >::pop_back(), and BCP_vec< T >::size().
void BCP_proc_array::clear | ( | ) | [inline] |
Purge all process ids from the process array.
Definition at line 135 of file BCP_message.hpp.
References _free_procs, _procs, BCP_vec< T >::clear(), and purge_ptr_vector().
void BCP_proc_array::add_procs | ( | BCP_vec< BCP_proc_id * >::const_iterator | first, | |
BCP_vec< BCP_proc_id * >::const_iterator | last | |||
) | [inline] |
Append the processes in [first,last)
to the end of the vector of all processes and mark them as free.
Definition at line 141 of file BCP_message.hpp.
References _free_procs, _procs, BCP_vec< T >::end(), and BCP_vec< T >::insert().
void BCP_proc_array::delete_proc | ( | const int | index | ) | [inline] |
Delete the process indexed by the argument from the vector of all processes (and also from the vector of free processes if applicable).
Definition at line 153 of file BCP_message.hpp.
References _free_procs, _procs, BCP_vec< T >::entry(), BCP_vec< T >::erase(), and BCP_vec< T >::size().
void BCP_proc_array::set_proc_free | ( | BCP_proc_id * | proc | ) | [inline] |
Append the process to the end of the vector of free processes.
The process to be set free must already be in the vector of all processes.
Definition at line 169 of file BCP_message.hpp.
References _free_procs, and BCP_vec< T >::push_back().
BCP_vec<BCP_proc_id*> BCP_proc_array::_procs [private] |
Vector of all processes.
Definition at line 74 of file BCP_message.hpp.
Referenced by add_procs(), busy_num(), clear(), delete_proc(), index_of_proc(), is_free_proc(), process(), procs(), size(), and ~BCP_proc_array().
BCP_vec<BCP_proc_id*> BCP_proc_array::_free_procs [private] |
Vector of free processes (subset of all processes).
Definition at line 76 of file BCP_message.hpp.
Referenced by add_procs(), busy_num(), clear(), delete_proc(), free_num(), get_free_proc(), is_free_proc(), and set_proc_free().