GridComputing
Job Management in Grid Computing
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
GridNetwork Class Reference

GridNetwork Class. More...

#include <gridnetwork.h>

Inheritance diagram for GridNetwork:
ISave IUpdate Runnable

Public Member Functions

 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.
 
GridGetGrid (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.
 
- Public Member Functions inherited from Runnable
 Runnable ()
 Constructor.
 
virtual ~Runnable ()
 Destructor. Stops thread.
 
void Stop ()
 Stops thread.
 
void Start ()
 Starts thread.
 

Static Public Member Functions

static GridNetworkLoad (ByteBuffer &bb)
 Returns a pointer to a Grid loaded from the given ByteBuffer.
 

Private Member Functions

void AddGrid (const std::string &name, Grid *grid)
 Add existing grid to the network.
 
void Run ()
 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.
 
 GridNetwork (const GridNetwork &)
 Copy constructor. Private to avoid copies of a GridManager instance.
 
GridNetworkoperator= (GridNetwork const &)
 Assignment operator. Private to avoid copies of a GridManager instance.
 

Private Attributes

std::map< std::string, Grid * > _bst
 Underlying binary search tree. Grids sorted by name.
 
uint64 _realPrevTime
 Time of the last update (ms)
 
uint64 _realCurrTime
 Time of the current update (ms)
 

Additional Inherited Members

- Protected Attributes inherited from Runnable
std::atomic< bool > _stop
 True if the thread should be stopped.
 

Detailed Description

GridNetwork Class.

The GridNetwork class is a collection of Grids, organized in a BST by name

Constructor & Destructor Documentation

GridNetwork::GridNetwork ( )
GridNetwork::~GridNetwork ( )

Destructor, deallocate all Grids.

GridNetwork::GridNetwork ( const GridNetwork )
private

Copy constructor. Private to avoid copies of a GridManager instance.

Member Function Documentation

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
predicateto 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.

GridNetwork * GridNetwork::Load ( ByteBuffer bb)
static

Returns a pointer to a Grid loaded from the given ByteBuffer.

Parameters
bbsource of the data.
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.

GridNetwork& GridNetwork::operator= ( GridNetwork const &  )
private

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.

bool GridNetwork::Save ( ByteBuffer bb) const
overridevirtual

Saves the information of the instance of the class to the given ByteBuffer.

Parameters
bbdestination 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
difftime that has passed since last update.

Implements IUpdate.

Member Data Documentation

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: