OpenASIP  2.0
Public Member Functions | Private Attributes | List of all members
ResourceMapper Class Reference

#include <ResourceMapper.hh>

Collaboration diagram for ResourceMapper:
Collaboration graph

Public Member Functions

 ResourceMapper ()
 
virtual ~ResourceMapper ()
 
void addResourceMap (const ResourceBroker &broker)
 
int resourceCount (const TTAMachine::MachinePart &mp) const
 
SchedulingResourceresourceOf (const TTAMachine::MachinePart &mp, int index=0) const
 

Private Attributes

std::vector< const ResourceBroker * > brokers_
 Resource brokers. More...
 

Detailed Description

Groups together the brokers managed by the resource build director and maps each resource object to corresponding machine parts.

Definition at line 51 of file ResourceMapper.hh.

Constructor & Destructor Documentation

◆ ResourceMapper()

ResourceMapper::ResourceMapper ( )

Constructor.

Definition at line 44 of file ResourceMapper.cc.

44  {
45 }

◆ ~ResourceMapper()

ResourceMapper::~ResourceMapper ( )
virtual

Destructor.

Definition at line 50 of file ResourceMapper.cc.

50  {
51 }

Member Function Documentation

◆ addResourceMap()

void ResourceMapper::addResourceMap ( const ResourceBroker broker)

Register broker as one of the elements that contribute to mapping a subset of machine parts to resources.

Parameters
brokerBroker to register.

Definition at line 60 of file ResourceMapper.cc.

60  {
62  string msg = "Broker already exists in resource map!";
63  throw ObjectAlreadyExists(__FILE__, __LINE__, __func__, msg);
64  } else {
65  brokers_.push_back(&broker);
66  }
67 }

References __func__, brokers_, and ContainerTools::containsValue().

Referenced by ResourceBuildDirector::build().

Here is the call graph for this function:

◆ resourceCount()

int ResourceMapper::resourceCount ( const TTAMachine::MachinePart mp) const

Return the number of resources that correspond to the given machine part.

Parameters
mpMachine part.
Returns
The number of resources that correspond to the given machine part.

Definition at line 76 of file ResourceMapper.cc.

76  {
77  int count = 0;
78  for (unsigned int i = 0; i < brokers_.size(); i++) {
79  if (brokers_[i]->hasResourceOf(mp)) {
80  count++;
81  }
82  }
83  return count;
84 }

References brokers_.

Referenced by OutputFUBroker::setupResourceLinks(), and InputFUBroker::setupResourceLinks().

◆ resourceOf()

SchedulingResource & ResourceMapper::resourceOf ( const TTAMachine::MachinePart mp,
int  index = 0 
) const

Find the resource object that corresponds to given machine part with index (default 0).

Parameters
mpMachine part to find Scheduling Resource for
indexIndex of machine part, in case there are several
Returns
The resource object that corresponds to given machine part and index.

Definition at line 96 of file ResourceMapper.cc.

96  {
97  const unsigned int brokerSize = brokers_.size();
98  for (unsigned int i = 0; i < brokerSize; i++) {
99  SchedulingResource* res = brokers_[i]->resourceOf(mp);
100  if (res != NULL) {
101  if (index == 0) {
102  return *res;
103  } else {
104  index--;
105  continue;
106  }
107  }
108  }
109  std::string errMsg = "None of the brokers has resource for part ";
110  const TTAMachine::Component * comp =
111  dynamic_cast<const TTAMachine::Component*>(&mp);
112  const TTAMachine::SubComponent * subcomp =
113  dynamic_cast<const TTAMachine::SubComponent*>(&mp);
114 
115  if (comp != NULL) {
116  errMsg += ": " + comp->name();
117  }
118  if (subcomp != NULL) {
119  errMsg += ", some subcomponent";
120  }
121 
122  throw KeyNotFound(__FILE__, __LINE__, __func__, errMsg);
123 }

References __func__, brokers_, and TTAMachine::Component::name().

Referenced by InputFUBroker::allAvailableResources(), ExecutionPipelineBroker::setupResourceLinks(), OutputFUBroker::setupResourceLinks(), InputFUBroker::setupResourceLinks(), OutputPSocketBroker::setupResourceLinks(), ITemplateBroker::setupResourceLinks(), and IUBroker::setupResourceLinks().

Here is the call graph for this function:

Member Data Documentation

◆ brokers_

std::vector<const ResourceBroker*> ResourceMapper::brokers_
private

Resource brokers.

Definition at line 63 of file ResourceMapper.hh.

Referenced by addResourceMap(), resourceCount(), and resourceOf().


The documentation for this class was generated from the following files:
TTAMachine::SubComponent
Definition: MachinePart.hh:168
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
SchedulingResource
Definition: SchedulingResource.hh:52
__func__
#define __func__
Definition: Application.hh:67
TTAMachine::Component
Definition: MachinePart.hh:90
ObjectAlreadyExists
Definition: Exception.hh:1002
ContainerTools::containsValue
static bool containsValue(const ContainerType &aContainer, const ElementType &aKey)
KeyNotFound
Definition: Exception.hh:285
ResourceMapper::brokers_
std::vector< const ResourceBroker * > brokers_
Resource brokers.
Definition: ResourceMapper.hh:63