OpenASIP 2.2
Loading...
Searching...
No Matches
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.
 
static const std::string OSKEY_FU = "fu"
 ObjectState attribute key for function unit name.
 
static const std::string OSKEY_PORT = "port"
 ObjectState attribute key for port name.
 
- Static Public Attributes inherited from TTAMachine::Guard
static const std::string OSNAME_GUARD = "guard"
 ObjectState name for guard.
 
static const std::string OSKEY_INVERTED = "inverted"
 ObjectState attribute key for inverted feature.
 

Private Attributes

FUPortport_
 Port from which the condition term is taken.
 

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}
FunctionUnit * parentUnit() const
Definition BaseFUPort.cc:96
void addGuard(Guard &guard)
Definition Bus.cc:410
virtual void ensureRegistration(const Component &component) const
virtual Bus * parentBus() const
Guard(bool inverted, Bus *parentBus)
Definition Guard.cc:64
FUPort * port_
Port from which the condition term is taken.
Definition Guard.hh:125
FUPort * port() const

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

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}
virtual TCEString name() const
void loadState(const ObjectState *state)
Definition Guard.cc:312
virtual std::string name() const
Definition Port.cc:141
virtual boost::format text(int textId)

References TTAMachine::Bus::addGuard(), loadState(), TTAMachine::Component::name(), TTAMachine::Port::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 }
virtual bool isInverted() const
PortGuard(bool inverted, FUPort &port, Bus &parentBus)
Definition Guard.cc:196

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

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}
std::string errorMessage() const
Definition Exception.cc:123
std::string stringAttribute(const std::string &name) const
std::string name() const
virtual Machine * machine() const
virtual void loadState(const ObjectState *state)
Definition Guard.cc:164
Navigator< FunctionUnit > FunctionUnitNavigator
Navigator type for FunctionUnitNavigator.
Definition Machine.hh:217
static const std::string OSKEY_PORT
ObjectState attribute key for port name.
Definition Guard.hh:121
static const std::string OSKEY_FU
ObjectState attribute key for function unit name.
Definition Guard.hh:119
static const std::string OSNAME_PORT_GUARD
ObjectState name for PortGuard ObjectState.
Definition Guard.hh:117

References Exception::errorMessage(), TTAMachine::Machine::functionUnitNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::Guard::loadState(), TTAMachine::Component::machine(), TTAMachine::Component::name(), ObjectState::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}
void setName(const std::string &name)
void setAttribute(const std::string &name, const std::string &value)
virtual ObjectState * saveState() const
Definition Guard.cc:149

References TTAMachine::Component::name(), TTAMachine::Port::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 ADFSerializer::busToMachine(), ADFSerializer::busToMDF(), 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 ADFSerializer::busToMachine(), ADFSerializer::busToMDF(), loadState(), and saveState().

◆ OSNAME_PORT_GUARD

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

◆ 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: