STK++ 1.0
STK::GProgram Class Reference

A GProgram is a succession of Step connected. More...

#include <STK_GProgram.h>

Inheritance diagram for STK::GProgram:
Collaboration diagram for STK::GProgram:

List of all members.

Public Member Functions

 GProgram (String const &name)
 constructor
virtual ~GProgram ()
 destructor
String const & name ()
 get the name_ of the program.
void run ()
 Execute the program.
void addStep (IStep *step)
 Add a step to the Program.
void removeStep (IStep *step)
 remove a step to the Program.
bool addConnection (IStep *source, IStep *target)
 Add a Connection between two steps of the Program.
virtual bool isPropertySet (String const &id) const
 Implementation of the pure virtual method isPropertySet defined in IPropertySource
virtual const StringgetPropertyValue (String const &id) const
 Implementation of the pure virtual method getPropertyValue defined in IPropertySource

Private Attributes

String name_
 name of the GProgram
std::list< IStep * > steps_
 list of the steps

Static Private Attributes

static const String ID_GPROGAM_NAME = "GProgram.name"
 Property ID for the name of the GProgram value.
static const PropertyDescriptor nameDescriptor_
 Descriptor of the name property.

Detailed Description

A GProgram is a succession of Step connected.

Each Step Perform a specific treatment.

Definition at line 51 of file STK_GProgram.h.


Constructor & Destructor Documentation

STK::GProgram::GProgram ( String const &  name)

constructor

Definition at line 51 of file STK_GProgram.cpp.

STK::GProgram::~GProgram ( ) [virtual]

destructor

Definition at line 55 of file STK_GProgram.cpp.

References steps_.

{
  std::list<IStep*>::iterator it;
  // remove steps in the program
  for (it=steps_.begin(); it!=steps_.end(); it++)
  {
    delete *it;
  }
}

Member Function Documentation

String const& STK::GProgram::name ( ) [inline]

get the name_ of the program.

Returns:
the name of the program

Definition at line 76 of file STK_GProgram.h.

References name_.

    {return name_;}
void STK::GProgram::run ( )

Execute the program.

Definition at line 66 of file STK_GProgram.cpp.

{;}
void STK::GProgram::addStep ( IStep step)

Add a step to the Program.

Parameters:
stepThe step to add

Definition at line 72 of file STK_GProgram.cpp.

References steps_.

Referenced by main().

{
  std::list<IStep*>::iterator it;
  // check if the step is already present
  for (it=steps_.begin(); it!=steps_.end(); it++)
  {
    if (*it == step) return;
  }
  steps_.push_back(step);
}
void STK::GProgram::removeStep ( IStep step)

remove a step to the Program.

Parameters:
stepThe step to remove

As a step can have incoming and outgoing connections, we have to remove safely all the stored values in the IStep connected with step.

Parameters:
stepThe step to remove

Definition at line 89 of file STK_GProgram.cpp.

References STK::IStep::getIncomingConnections(), STK::Connection::getSource(), STK::IStep::removeConnection(), and steps_.

Referenced by main().

{
  std::list<Connection*>& incomingConnection = step->getIncomingConnections();
  std::list<Connection*>::iterator it;
  // remove the incoming Connections
  for (it=incomingConnection.begin(); it!=incomingConnection.end(); it++)
  {
    Connection* arc = *it;
    arc->getSource()->removeConnection(arc);
  }
  // remove the IStep
  steps_.remove(step);
  delete step;
}

Here is the call graph for this function:

bool STK::GProgram::addConnection ( IStep source,
IStep target 
)

Add a Connection between two steps of the Program.

addConnection check if the Connection will not create an infinite loop in the program. Return false if it is the case.

The method will ask to the target Step if the Connection is compatible. If the Connection is compatible the Connection is created and added to the list of incoming Connection to the target Step and the outgoing Connection of the source Step

See also:
IStep::addConnection
Parameters:
sourceThe source of the Connection
targetThe target of the Connection
Returns:
true if the Connection have been added

addConnection check if the Connection will not create an infinite loop in the program. Return false if it is the case. Then the method will ask to the target Step if the Connection is compatible. If the Connection is compatible the Connection is created and added to the list of incoming Connection to the target Step and the outgoing Connection of the source Step

See also:
IStep::addConnection
Parameters:
sourceThe source of the Connection
targetThe target of the Connection
Returns:
true if the Connection have been added

Definition at line 119 of file STK_GProgram.cpp.

References STK::IStep::addConnection().

Referenced by main().

{
  // TODO Check for an infinite loop in the program
  // no loop we create the connection and add it
  Connection* arc = new Connection(source, target);
  source->addConnection(arc);
  target->addConnection(arc);
  return true;
}

Here is the call graph for this function:

bool STK::GProgram::isPropertySet ( String const &  id) const [virtual]

Implementation of the pure virtual method isPropertySet defined in IPropertySource

See also:
IPropertySource::isPropertySet
Parameters:
idthe id of the property
Returns:
true if id is a valid IStep id property.

Implements STK::IPropertySource.

Definition at line 134 of file STK_GProgram.cpp.

References ID_GPROGAM_NAME.

{
  if (id==ID_GPROGAM_NAME)
  { return true;}
  return false;
}
const String * STK::GProgram::getPropertyValue ( String const &  id) const [virtual]

Implementation of the pure virtual method getPropertyValue defined in IPropertySource

See also:
IPropertySource::getPropertValue
Parameters:
idthe id of the property
Returns:
the value of the property, or NA

Implements STK::IPropertySource.

Definition at line 149 of file STK_GProgram.cpp.

References name_.

{
  return &name_;
}

Member Data Documentation

const String STK::GProgram::ID_GPROGAM_NAME = "GProgram.name" [static, private]

Property ID for the name of the GProgram value.

Definition at line 55 of file STK_GProgram.h.

Referenced by isPropertySet().

Descriptor of the name property.

Definition at line 58 of file STK_GProgram.h.

name of the GProgram

Definition at line 61 of file STK_GProgram.h.

Referenced by getPropertyValue(), and name().

std::list<IStep*> STK::GProgram::steps_ [private]

list of the steps

Definition at line 64 of file STK_GProgram.h.

Referenced by addStep(), removeStep(), and ~GProgram().


The documentation for this class was generated from the following files: