GridNetwork Class.
More...
#include <gridnetwork.h>
|
| GridNetwork () |
|
| ~GridNetwork () |
| Destructor, deallocate all Grids.
|
|
void | NewGrid (const std::string &name, const std::string &topic) |
| Add a new Grid to the network with the given name and topic.
|
|
void | ChangeGridName (const std::string &oldName, const std::string &newName) |
| Change the name of an existing Grid.
|
|
void | ChangeGridTopic (const std::string &name, const std::string &newTopic) |
| Change the topic of an existing Grid.
|
|
void | RemoveGrid (const std::string &name) |
| Remove a Grid from the Network.
|
|
Grid * | GetGrid (const std::string &name) |
| Returns a pointer to an existing Grid.
|
|
bool | Save (ByteBuffer &bb) const override |
| Saves the information of the instance of the class to the given ByteBuffer.
|
|
void | Update (uint32 diff) |
| Update function that updates all grids. It removes finished jobs and updates the respective machines.
|
|
const std::map< std::string,
Grid * > & | GetContainer () const |
| Returns the underlying Grid container.
|
|
std::vector< const Grid * > | ApplyPredicate (std::function< bool(const Grid *)> predicate) const |
| Applies the given predicate to the Grids stored in this GridNetwork and returns a vector with the values that meet the requirement.
|
|
| Runnable () |
| Constructor.
|
|
virtual | ~Runnable () |
| Destructor. Stops thread.
|
|
void | Stop () |
| Stops thread.
|
|
void | Start () |
| Starts thread.
|
|
|
std::atomic< bool > | _stop |
| True if the thread should be stopped.
|
|
GridNetwork Class.
The GridNetwork class is a collection of Grids, organized in a BST by name
GridNetwork::GridNetwork |
( |
| ) |
|
GridNetwork::~GridNetwork |
( |
| ) |
|
Destructor, deallocate all Grids.
Copy constructor. Private to avoid copies of a GridManager instance.
void GridNetwork::AddGrid |
( |
const std::string & |
name, |
|
|
Grid * |
grid |
|
) |
| |
|
private |
Add existing grid to the network.
std::vector< const Grid * > GridNetwork::ApplyPredicate |
( |
std::function< bool(const Grid *)> |
predicate | ) |
const |
Applies the given predicate to the Grids stored in this GridNetwork and returns a vector with the values that meet the requirement.
- Parameters
-
predicate | to evaluate the data: unary function that returns a bool and accepts a Grid* as argument. |
- Returns
- A vector with the result of the search.
void GridNetwork::ChangeGridName |
( |
const std::string & |
oldName, |
|
|
const std::string & |
newName |
|
) |
| |
Change the name of an existing Grid.
void GridNetwork::ChangeGridTopic |
( |
const std::string & |
name, |
|
|
const std::string & |
newTopic |
|
) |
| |
Change the topic of an existing Grid.
const std::map<std::string, Grid*>& GridNetwork::GetContainer |
( |
| ) |
const |
Returns the underlying Grid container.
Grid * GridNetwork::GetGrid |
( |
const std::string & |
name | ) |
|
Returns a pointer to an existing Grid.
Returns a pointer to a Grid loaded from the given ByteBuffer.
- Parameters
-
- Returns
- A pointer to the loaded Grid.
void GridNetwork::NewGrid |
( |
const std::string & |
name, |
|
|
const std::string & |
topic |
|
) |
| |
Add a new Grid to the network with the given name and topic.
Assignment operator. Private to avoid copies of a GridManager instance.
void GridNetwork::RemoveGrid |
( |
const std::string & |
name | ) |
|
Remove a Grid from the Network.
void GridNetwork::Run |
( |
| ) |
|
|
privatevirtual |
Calls update functions of all the elements of the class, that can be updated, two times per second. It saves the GridNetwork to file every 5 seconds.
Implements Runnable.
Saves the information of the instance of the class to the given ByteBuffer.
- Parameters
-
bb | destination of the data. |
- Returns
- A boolean value that indicates whether the save was successful or not.
Implements ISave.
void GridNetwork::Update |
( |
uint32 |
diff | ) |
|
|
virtual |
Update function that updates all grids. It removes finished jobs and updates the respective machines.
- Parameters
-
diff | time that has passed since last update. |
Implements IUpdate.
std::map<std::string, Grid*> GridNetwork::_bst |
|
private |
Underlying binary search tree. Grids sorted by name.
uint64 GridNetwork::_realCurrTime |
|
private |
Time of the current update (ms)
uint64 GridNetwork::_realPrevTime |
|
private |
Time of the last update (ms)
The documentation for this class was generated from the following files: