OpenASIP  2.0
Classes | Public Member Functions | Private Types | Private Attributes | List of all members
SchedulingResourceSet Class Reference

#include <SchedulingResource.hh>

Collaboration diagram for SchedulingResourceSet:
Collaboration graph

Classes

struct  less_name
 

Public Member Functions

 SchedulingResourceSet ()
 
 ~SchedulingResourceSet ()
 
void insert (SchedulingResource &resource)
 
int count () const
 
SchedulingResourceresource (int index) const
 
void remove (SchedulingResource &resource)
 
SchedulingResourceSetoperator= (const SchedulingResourceSet &newSet)
 
void sort ()
 
void clear ()
 
bool hasResource (SchedulingResource &res)
 

Private Types

typedef std::vector< SchedulingResource * > ResourceList
 

Private Attributes

ResourceList resources_
 

Detailed Description

Set of scheduling resources.

Definition at line 161 of file SchedulingResource.hh.

Member Typedef Documentation

◆ ResourceList

Definition at line 175 of file SchedulingResource.hh.

Constructor & Destructor Documentation

◆ SchedulingResourceSet()

SchedulingResourceSet::SchedulingResourceSet ( )

Constructor.

Definition at line 222 of file SchedulingResource.cc.

222 {}

◆ ~SchedulingResourceSet()

SchedulingResourceSet::~SchedulingResourceSet ( )

Destructor.

Definition at line 227 of file SchedulingResource.cc.

227 {}

Member Function Documentation

◆ clear()

void SchedulingResourceSet::clear ( )

Clears the scheduling resource set.

Definition at line 336 of file SchedulingResource.cc.

336  {
337  resources_.clear();
338 }

References resources_.

Referenced by PendingAssignment::clear().

◆ count()

int SchedulingResourceSet::count ( ) const

◆ hasResource()

bool SchedulingResourceSet::hasResource ( SchedulingResource resource)

Tells whether the set has the given resource.

Definition at line 297 of file SchedulingResource.cc.

297  {
298  ResourceList::iterator iter = resources_.begin();
299  while (iter != resources_.end()) {
300  if ((*iter) == &resource) {
301  return true;
302  }
303  iter++;
304  }
305  return false;
306 }

References resource(), and resources_.

Here is the call graph for this function:

◆ insert()

void SchedulingResourceSet::insert ( SchedulingResource resource)

Insert a scheduling resource in the set.

Parameters
resourceResource to insert.
Exceptions
ObjectAlreadyExistsif the resource is already in the set.

Definition at line 236 of file SchedulingResource.cc.

236  {
237 
239  throw ObjectAlreadyExists(__FILE__, __LINE__, __func__);
240  } else {
241  resources_.push_back(&resource);
242  }
243 }

References __func__, ContainerTools::containsValue(), resource(), and resources_.

Referenced by OutputFUBroker::allAvailableResources(), InputPSocketBroker::allAvailableResources(), InputFUBroker::allAvailableResources(), OutputPSocketBroker::allAvailableResources(), IUBroker::allAvailableResources(), BusBroker::allAvailableResources(), ITemplateBroker::findITemplates(), and operator=().

Here is the call graph for this function:

◆ operator=()

SchedulingResourceSet & SchedulingResourceSet::operator= ( const SchedulingResourceSet newSet)

Assignment operator.

Parameters
newSetSet to assign resources from.
Returns
This set with newly assigned contents.

Definition at line 315 of file SchedulingResource.cc.

315  {
316  resources_.clear();
317  for (int i = 0; i < newSet.count(); i++) {
318  insert(newSet.resource(i));
319  }
320  return *this;
321 }

References count(), insert(), resource(), and resources_.

Here is the call graph for this function:

◆ remove()

void SchedulingResourceSet::remove ( SchedulingResource resource)

Remove a resource from the set.

Parameters
resourceScheduling resource to be removed.
Exceptions
KeyNotFoundIf given resource is not found in the set.

Definition at line 279 of file SchedulingResource.cc.

279  {
280 
281  ResourceList::iterator iter = resources_.begin();
282  while (iter != resources_.end()) {
283  if ((*iter) == &resource) {
284  resources_.erase(iter);
285  return;
286  }
287  iter++;
288  }
289  string msg = "Resource not found in resource set.";
290  throw KeyNotFound(__FILE__, __LINE__, __func__, msg);
291 }

References __func__, resource(), and resources_.

Referenced by BusBroker::allAvailableResources().

Here is the call graph for this function:

◆ resource()

SchedulingResource & SchedulingResourceSet::resource ( int  index) const

Return the resource at the given position.

Parameters
indexPosition of resource.
Returns
The resource at the given position.
Exceptions
OutOfRangeIf the given position exceeds number of resources.

Definition at line 263 of file SchedulingResource.cc.

263  {
264 
265  if (index < 0 || index >= static_cast<int>(resources_.size())) {
266  throw OutOfRange(__FILE__, __LINE__, __func__);
267  } else {
268  return *resources_.at(index);
269  }
270 }

References __func__, and resources_.

Referenced by BusBroker::allAvailableResources(), BusBroker::availableResource(), hasResource(), insert(), ITemplateBroker::instruction(), operator=(), remove(), PendingAssignment::resource(), and PendingAssignment::tryNext().

◆ sort()

void SchedulingResourceSet::sort ( )

Sort the content of Scheduling Resource Set by the names of the resources.

Definition at line 328 of file SchedulingResource.cc.

328  {
329  std::sort(resources_.begin(), resources_.end(), less_name());
330 }

References resources_.

Referenced by ITemplateBroker::findITemplates(), and PendingAssignment::isAssignmentPossible().

Member Data Documentation

◆ resources_

ResourceList SchedulingResourceSet::resources_
private

Definition at line 184 of file SchedulingResource.hh.

Referenced by clear(), count(), hasResource(), insert(), operator=(), remove(), resource(), and sort().


The documentation for this class was generated from the following files:
OutOfRange
Definition: Exception.hh:320
__func__
#define __func__
Definition: Application.hh:67
SchedulingResourceSet::count
int count() const
Definition: SchedulingResource.cc:251
ObjectAlreadyExists
Definition: Exception.hh:1002
SchedulingResourceSet::resources_
ResourceList resources_
Definition: SchedulingResource.hh:184
ContainerTools::containsValue
static bool containsValue(const ContainerType &aContainer, const ElementType &aKey)
KeyNotFound
Definition: Exception.hh:285
SchedulingResourceSet::resource
SchedulingResource & resource(int index) const
Definition: SchedulingResource.cc:263
SchedulingResourceSet::insert
void insert(SchedulingResource &resource)
Definition: SchedulingResource.cc:236