OpenASIP  2.0
Public Member Functions | Static Public Attributes | Private Attributes | List of all members
TTAMachine::PortGuard Class Reference

#include <Guard.hh>

Inheritance diagram for TTAMachine::PortGuard:
Inheritance graph
Collaboration diagram for TTAMachine::PortGuard:
Collaboration graph

Public Member Functions

 PortGuard (bool inverted, FUPort &port, Bus &parentBus)
 
 PortGuard (const ObjectState *state, Bus &parentBus)
 
virtual ~PortGuard ()
 
bool isEqual (const Guard &guard) const
 
bool isOpposite (const Guard &guard) const
 
FUPortport () const
 
virtual void copyTo (Bus &parentBus) const
 
ObjectStatesaveState () const
 
void loadState (const ObjectState *state)
 
- Public Member Functions inherited from TTAMachine::Guard
virtual ~Guard ()
 
virtual BusparentBus () const
 
virtual void setParentBus (Bus *parentBus)
 
virtual bool isInverted () const
 
virtual bool isMoreRestrictive (const Guard &guard) const
 
virtual bool isLessRestrictive (const Guard &guard) const
 
virtual bool isDisjoint (const Guard &guard) const
 
- Public Member Functions inherited from Serializable
virtual ~Serializable ()
 

Static Public Attributes

static const std::string OSNAME_PORT_GUARD = "portguard"
 ObjectState name for PortGuard ObjectState. More...
 
static const std::string OSKEY_FU = "fu"
 ObjectState attribute key for function unit name. More...
 
static const std::string OSKEY_PORT = "port"
 ObjectState attribute key for port name. More...
 
- Static Public Attributes inherited from TTAMachine::Guard
static const std::string OSNAME_GUARD = "guard"
 ObjectState name for guard. More...
 
static const std::string OSKEY_INVERTED = "inverted"
 ObjectState attribute key for inverted feature. More...
 

Private Attributes

FUPortport_
 Port from which the condition term is taken. More...
 

Additional Inherited Members

- Protected Member Functions inherited from TTAMachine::Guard
 Guard (bool inverted, Bus *parentBus)
 
 Guard (const ObjectState *state, Bus &parentBus)
 
- Protected Member Functions inherited from TTAMachine::SubComponent
 SubComponent ()
 
virtual ~SubComponent ()
 
- Protected Member Functions inherited from TTAMachine::MachinePart
 MachinePart ()
 
virtual ~MachinePart ()
 

Detailed Description

Guard where the condition term is taken from the value of an output port of a FunctionUnit.

Definition at line 99 of file Guard.hh.

Constructor & Destructor Documentation

◆ PortGuard() [1/2]

TTAMachine::PortGuard::PortGuard ( bool  inverted,
FUPort port,
Bus parentBus 
)

Constructor.

Parameters
invertedIncates whether the condition term is inverted.
portPort from which the condition term is taken.
parentBusParent bus component of the guard.
Exceptions
IllegalRegistrationIf the given port is not registered to the same machine as the given parent bus.
ComponentAlreadyExistsIf the parent bus already has an equal guard.

Definition at line 196 of file Guard.cc.

197  : Guard(inverted, &parentBus), port_(&port) {
198  FunctionUnit* unit = port.parentUnit();
200  parentBus.addGuard(*this);
201 }

References TTAMachine::Bus::addGuard(), TTAMachine::Component::ensureRegistration(), TTAMachine::Guard::parentBus(), TTAMachine::BaseFUPort::parentUnit(), and port().

Referenced by copyTo().

Here is the call graph for this function:

◆ PortGuard() [2/2]

TTAMachine::PortGuard::PortGuard ( const ObjectState state,
Bus parentBus 
)

Constructor.

Loads its state from the given ObjectState instance.

Parameters
stateThe ObjectState instance.
parentBusParent bus of the guard.
Exceptions
ObjectStateLoadingExceptionIf the reference to the function unit port cannot be resolved or if the given ObjectState instance is invalid.

Definition at line 215 of file Guard.cc.

216  : Guard(state, parentBus) {
217  loadState(state);
218  try {
219  parentBus.addGuard(*this);
220  } catch (const ComponentAlreadyExists&) {
221  const string procName = "PortGuard::PortGuard";
222  MOMTextGenerator textGen;
223  format errorMsg = textGen.text(
225  errorMsg % port()->name() % port()->parentUnit()->name() %
226  parentBus.name();
228  __FILE__, __LINE__, procName, errorMsg.str());
229  }
230 }

References TTAMachine::Bus::addGuard(), loadState(), TTAMachine::Port::name(), TTAMachine::Component::name(), TTAMachine::Guard::parentBus(), TTAMachine::BaseFUPort::parentUnit(), port(), Texts::TextGenerator::text(), and MOMTextGenerator::TXT_EQUAL_PORT_GUARDS.

Here is the call graph for this function:

◆ ~PortGuard()

TTAMachine::PortGuard::~PortGuard ( )
virtual

Destructor.

Definition at line 235 of file Guard.cc.

235  {
236 }

Member Function Documentation

◆ copyTo()

virtual void TTAMachine::PortGuard::copyTo ( Bus parentBus) const
inlinevirtual

Implements TTAMachine::Guard.

Definition at line 109 of file Guard.hh.

109  {
111  }

References TTAMachine::Guard::isInverted(), TTAMachine::Guard::parentBus(), port_, and PortGuard().

Here is the call graph for this function:

◆ isEqual()

bool TTAMachine::PortGuard::isEqual ( const Guard guard) const
virtual

Returns true if the guard is equal with the given guard.

Parameters
guardThe other guard.
Returns
True if the guard is equal with the given guard.

Implements TTAMachine::Guard.

Definition at line 246 of file Guard.cc.

246  {
247  const PortGuard* portGuard = dynamic_cast<const PortGuard*>(&guard);
248  if (portGuard == NULL) {
249  return false;
250  } else {
251  if (port() == portGuard->port() &&
252  isInverted() == portGuard->isInverted()) {
253  return true;
254  } else {
255  return false;
256  }
257  }
258 }

References TTAMachine::Guard::isInverted(), and port().

Here is the call graph for this function:

◆ isOpposite()

bool TTAMachine::PortGuard::isOpposite ( const Guard guard) const
virtual

Returns true if the guard is opposite with the given guard, ie. always if one is executed, another is not executed.

Parameters
guardThe other guard.
Returns
True if the guard is opposite with the given guard.

Implements TTAMachine::Guard.

Definition at line 268 of file Guard.cc.

268  {
269  const PortGuard* portGuard = dynamic_cast<const PortGuard*>(&guard);
270  if (portGuard == NULL) {
271  return false;
272  } else {
273  if (port() == portGuard->port() &&
274  isInverted() != portGuard->isInverted()) {
275  return true;
276  } else {
277  return false;
278  }
279  }
280 }

References TTAMachine::Guard::isInverted(), and port().

Here is the call graph for this function:

◆ loadState()

void TTAMachine::PortGuard::loadState ( const ObjectState state)
virtual

Loads its state from the given ObjectState instance.

Parameters
stateThe ObjectState instance.
Exceptions
ObjectStateLoadingExceptionIf the given ObjectState instance is invalid or if the reference to the function unit port cannot be resolved.

Reimplemented from TTAMachine::Guard.

Definition at line 312 of file Guard.cc.

312  {
313  string procName = "PortGuard::loadState";
314  MOMTextGenerator textGenerator;
315 
316  if (state->name() != OSNAME_PORT_GUARD) {
317  throw ObjectStateLoadingException(__FILE__, __LINE__, procName);
318  }
319 
320  Guard::loadState(state);
321 
322  try {
323  string fuName = state->stringAttribute(OSKEY_FU);
324  string portName = state->stringAttribute(OSKEY_PORT);
325 
326  Machine* mach = parentBus()->machine();
327  if (mach == NULL) {
328  format text = textGenerator.text(MOMTextGenerator::
329  TXT_GUARD_REF_LOAD_ERR);
330  text % parentBus()->name();
331  throw ObjectStateLoadingException(__FILE__, __LINE__, procName,
332  text.str());
333  }
334 
335  Machine::FunctionUnitNavigator fuNav = mach->functionUnitNavigator();
336  FunctionUnit* fu = NULL;
337  FUPort* port = NULL;
338 
339  try {
340  fu = fuNav.item(fuName);
341  } catch (InstanceNotFound& e) {
342  format text = textGenerator.text(MOMTextGenerator::
343  TXT_GUARD_REF_LOAD_ERR_FU);
344  text % parentBus()->name() % fuName;
345  throw ObjectStateLoadingException(__FILE__, __LINE__, procName,
346  text.str());
347  }
348 
349  try {
350  port = fu->operationPort(portName);
351  } catch (InstanceNotFound& e) {
352  format text = textGenerator.text(MOMTextGenerator::
353  TXT_GUARD_REF_LOAD_ERR_PORT);
354  text % parentBus()->name() % portName % fuName;
355  throw ObjectStateLoadingException(__FILE__, __LINE__, procName,
356  text.str());
357  }
358 
359  port_ = port;
360 
361  } catch (Exception& e) {
362  throw ObjectStateLoadingException(__FILE__, __LINE__, procName,
363  e.errorMessage());
364  }
365 }

References Exception::errorMessage(), TTAMachine::Machine::functionUnitNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::Guard::loadState(), TTAMachine::Component::machine(), ObjectState::name(), TTAMachine::Component::name(), TTAMachine::FunctionUnit::operationPort(), OSKEY_FU, OSKEY_PORT, OSNAME_PORT_GUARD, TTAMachine::Guard::parentBus(), port(), port_, ObjectState::stringAttribute(), and Texts::TextGenerator::text().

Referenced by PortGuard().

Here is the call graph for this function:

◆ port()

FUPort* TTAMachine::PortGuard::port ( ) const

◆ saveState()

ObjectState * TTAMachine::PortGuard::saveState ( ) const
virtual

Saves the contents to an ObjectState object.

Returns
The created tree ObjectState object.

Reimplemented from TTAMachine::Guard.

Definition at line 289 of file Guard.cc.

289  {
290 
291  ObjectState* guardState = Guard::saveState();
292  guardState->setName(OSNAME_PORT_GUARD);
293 
294  FunctionUnit* unit = port_->parentUnit();
295  guardState->setAttribute(OSKEY_FU, unit->name());
296  guardState->setAttribute(OSKEY_PORT, port_->name());
297 
298  return guardState;
299 }

References TTAMachine::Port::name(), TTAMachine::Component::name(), OSKEY_FU, OSKEY_PORT, OSNAME_PORT_GUARD, TTAMachine::BaseFUPort::parentUnit(), port_, TTAMachine::Guard::saveState(), ObjectState::setAttribute(), and ObjectState::setName().

Here is the call graph for this function:

Member Data Documentation

◆ OSKEY_FU

const string TTAMachine::PortGuard::OSKEY_FU = "fu"
static

ObjectState attribute key for function unit name.

Definition at line 119 of file Guard.hh.

Referenced by loadState(), and saveState().

◆ OSKEY_PORT

const string TTAMachine::PortGuard::OSKEY_PORT = "port"
static

ObjectState attribute key for port name.

Definition at line 121 of file Guard.hh.

Referenced by loadState(), and saveState().

◆ OSNAME_PORT_GUARD

const string TTAMachine::PortGuard::OSNAME_PORT_GUARD = "portguard"
static

ObjectState name for PortGuard ObjectState.

Definition at line 117 of file Guard.hh.

Referenced by TTAMachine::Bus::loadState(), loadState(), and saveState().

◆ port_

FUPort* TTAMachine::PortGuard::port_
private

Port from which the condition term is taken.

Definition at line 125 of file Guard.hh.

Referenced by copyTo(), loadState(), and saveState().


The documentation for this class was generated from the following files:
TTAMachine::Guard::saveState
virtual ObjectState * saveState() const
Definition: Guard.cc:149
TTAMachine::PortGuard::loadState
void loadState(const ObjectState *state)
Definition: Guard.cc:312
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
ObjectState::stringAttribute
std::string stringAttribute(const std::string &name) const
Definition: ObjectState.cc:249
TTAMachine::PortGuard::port
FUPort * port() const
ObjectStateLoadingException
Definition: Exception.hh:551
TTAMachine::BaseFUPort::parentUnit
FunctionUnit * parentUnit() const
Definition: BaseFUPort.cc:96
TTAMachine::PortGuard::port_
FUPort * port_
Port from which the condition term is taken.
Definition: Guard.hh:125
TTAMachine::Component::ensureRegistration
virtual void ensureRegistration(const Component &component) const
Definition: MachinePart.cc:163
ObjectState
Definition: ObjectState.hh:59
TTAMachine::Bus::addGuard
void addGuard(Guard &guard)
Definition: Bus.cc:410
Texts::TextGenerator::text
virtual boost::format text(int textId)
Definition: TextGenerator.cc:94
ObjectState::setName
void setName(const std::string &name)
TTAMachine::Machine::FunctionUnitNavigator
Navigator< FunctionUnit > FunctionUnitNavigator
Navigator type for FunctionUnitNavigator.
Definition: Machine.hh:217
MOMTextGenerator::TXT_EQUAL_PORT_GUARDS
@ TXT_EQUAL_PORT_GUARDS
Definition: MOMTextGenerator.hh:52
TTAMachine::PortGuard::OSKEY_PORT
static const std::string OSKEY_PORT
ObjectState attribute key for port name.
Definition: Guard.hh:121
TTAMachine::Guard::Guard
Guard(bool inverted, Bus *parentBus)
Definition: Guard.cc:64
Exception
Definition: Exception.hh:54
ObjectState::name
std::string name() const
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
TTAMachine::Guard::parentBus
virtual Bus * parentBus() const
TTAMachine::Guard::isInverted
virtual bool isInverted() const
TTAMachine::Component::machine
virtual Machine * machine() const
TTAMachine::Port::name
virtual std::string name() const
Definition: Port.cc:141
MOMTextGenerator
Definition: MOMTextGenerator.hh:40
TTAMachine::Guard::loadState
virtual void loadState(const ObjectState *state)
Definition: Guard.cc:164
ComponentAlreadyExists
Definition: Exception.hh:510
TTAMachine::PortGuard::OSKEY_FU
static const std::string OSKEY_FU
ObjectState attribute key for function unit name.
Definition: Guard.hh:119
TTAMachine::PortGuard::PortGuard
PortGuard(bool inverted, FUPort &port, Bus &parentBus)
Definition: Guard.cc:196
TTAMachine::PortGuard::OSNAME_PORT_GUARD
static const std::string OSNAME_PORT_GUARD
ObjectState name for PortGuard ObjectState.
Definition: Guard.hh:117
ObjectState::setAttribute
void setAttribute(const std::string &name, const std::string &value)
Definition: ObjectState.cc:100
InstanceNotFound
Definition: Exception.hh:304