STK++ 1.0
STK::Connection Class Reference

A connection between two distinct Steps in a program. More...

#include <STK_Connection.h>

Inheritance diagram for STK::Connection:
Collaboration diagram for STK::Connection:

List of all members.

Public Types

enum  PenStyle {
  NoPen, SolidLine, DashLine, DotLine,
  DashDotLine, DashDotDotLine, CustomDashLine
}

Public Member Functions

 Connection (IStep *source, IStep *target, const PenStyle &lineStyle=SolidLine)
 constructor
virtual ~Connection ()
 destructor.
const PenStylegetLineStyle () const
 Returns the line drawing style of this connection.
IStepgetSource () const
 Returns the source end-point of this connection.
IStepgetTarget () const
 Returns the target end-point of this connection.
void setLineStyle (const PenStyle &lineStyle)
 Set the line drawing style of this connection.
void disconnect ()
 Disconnect this connection from the Steps it is attached to.
void reconnect ()
 Reconnect this connection.
void reconnect (IStep *newSource, IStep *newTarget)
 Reconnect to a different source and/or target Step.
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

Protected Attributes

bool isConnected_
 True, if the connection is attached to its end-points.
PenStyle lineStyle_
 Default Line drawing style for this connection.
IStepsource_
 Connection's source end-point.
ISteptarget_
 Connection's target end-point.

Static Private Attributes

static const String ID_CONNECTION_LINESTYLE
 Property ID to use for the line style property.
static const String ID_CONNECTION_SOURCE
 Property ID to use for tjhe source property.
static const String ID_CONNECTION_TARGET
 Property ID to use for the target property.
static const PropertyDescriptor lineStyleDescriptor_
 Descriptor of the line style property.
static const PropertyDescriptor sourceDescriptor_
 Descriptor of source property.
static const PropertyDescriptor targetDescriptor_
 Descriptor of the target property.
static const String lineStyleName []
 Values of the line style Property.

Detailed Description

A connection between two distinct Steps in a program.

When designing a program, the user will connect the different step of its program with Connection

Definition at line 53 of file STK_Connection.h.


Member Enumeration Documentation

Enumerator:
NoPen 
SolidLine 
DashLine 
DotLine 
DashDotLine 
DashDotDotLine 
CustomDashLine 

Definition at line 56 of file STK_Connection.h.


Constructor & Destructor Documentation

STK::Connection::Connection ( IStep source,
IStep target,
const PenStyle lineStyle = SolidLine 
)

constructor

Create a (solid) connection between two distinct Steps.

Parameters:
sourcea source end-point for this connection (non null)
targeta target end-point for this connection (non null)
lineStyleline style to use for the Connection
See also:
Connection::setLineStyle

Definition at line 72 of file STK_Connection.cpp.

                      : lineStyle_(lineStyle)
                      , source_(source)
                      , target_(target)
{ ;}
STK::Connection::~Connection ( ) [virtual]

destructor.

Definition at line 82 of file STK_Connection.cpp.

{ ;}

Member Function Documentation

const Connection::PenStyle & STK::Connection::getLineStyle ( ) const

Returns the line drawing style of this connection.

Returns:
a Qt::PenStyle

Definition at line 89 of file STK_Connection.cpp.

References lineStyle_.

{ return lineStyle_;}
IStep * STK::Connection::getSource ( ) const

Returns the source end-point of this connection.

Returns the source endpoint of this connection.

Returns:
a non-null IStep instance
a non-null IStep pointer

Definition at line 95 of file STK_Connection.cpp.

References source_.

Referenced by STK::IStep::addConnection(), STK::IStep::removeConnection(), and STK::GProgram::removeStep().

{ return source_;}
IStep * STK::Connection::getTarget ( ) const

Returns the target end-point of this connection.

Returns the target endpoint of this connection.

Returns:
a non-null IStep instance
a non-null IStep pointer

Definition at line 101 of file STK_Connection.cpp.

References target_.

Referenced by STK::IStep::addConnection(), and STK::IStep::removeConnection().

{ return target_;}
void STK::Connection::setLineStyle ( const PenStyle lineStyle)

Set the line drawing style of this connection.

Parameters:
lineStyleone of the values in Qt::PenStyle except NoPen
See also:
Qt::PenStyle
Exceptions:
invalid_argumentif lineStyle is Qt::NoPen
Parameters:
lineStyleone of the Qt::PenStyle values
See also:
Qt::PenStyle
Exceptions:
IllegalArgumentExceptionif lineStyle does not have one of the above values

Definition at line 110 of file STK_Connection.cpp.

References lineStyle_, and NoPen.

{
  if (lineStyle == NoPen)
  {
    throw std::invalid_argument("In Connection::setLineStyle : try to set"
                                "NoPen style");
  }
  lineStyle_ = lineStyle;
}
void STK::Connection::disconnect ( )

Disconnect this connection from the Steps it is attached to.

Definition at line 123 of file STK_Connection.cpp.

References isConnected_, STK::IStep::removeConnection(), source_, and target_.

Referenced by reconnect().

{
  if (isConnected_)
  {
    source_->removeConnection(this);
    target_->removeConnection(this);
    isConnected_ = false;
  }
}

Here is the call graph for this function:

void STK::Connection::reconnect ( )

Reconnect this connection.

The connection will reconnect with the step it was previously attached to.

Definition at line 137 of file STK_Connection.cpp.

References STK::IStep::addConnection(), isConnected_, source_, and target_.

Referenced by reconnect().

{
  if (!isConnected_)
  {
    source_->addConnection(this);
    target_->addConnection(this);
    isConnected_ = true;
  }
}

Here is the call graph for this function:

void STK::Connection::reconnect ( IStep newSource,
IStep newTarget 
)

Reconnect to a different source and/or target Step.

The connection will disconnect from its current attachments and reconnect to the new source and target.

Parameters:
newSourcea new source end-point for this connection (non null)
newTargeta new target end-point for this connection (non null)
Exceptions:
invalid_argumentif any of the parameters are null or newSource == newTarget

Definition at line 151 of file STK_Connection.cpp.

References disconnect(), reconnect(), source_, and target_.

{
  if (newSource == newTarget)
  {
    throw std::invalid_argument("STK::Connection::reconnect(newSource, newTarget"
                                " source and target must be different"
                               );
  }
  disconnect();
  this->source_ = newSource;
  this->target_ = newTarget;
  reconnect();
}

Here is the call graph for this function:

bool STK::Connection::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 Connection id property.

Implements STK::IPropertySource.

Definition at line 172 of file STK_Connection.cpp.

References ID_CONNECTION_LINESTYLE, ID_CONNECTION_SOURCE, ID_CONNECTION_TARGET, and isConnected_.

{
  if (id==ID_CONNECTION_LINESTYLE) return true;
  if ((id==ID_CONNECTION_SOURCE||id==ID_CONNECTION_TARGET)&&
      (isConnected_)) return true;
  return false;
}
const String * STK::Connection::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 188 of file STK_Connection.cpp.

References ID_CONNECTION_LINESTYLE, ID_CONNECTION_SOURCE, ID_CONNECTION_TARGET, isConnected_, lineStyle_, lineStyleName, STK::IStep::name(), source_, and target_.

{
  // line  style name
  if (id==ID_CONNECTION_LINESTYLE)
    return &(lineStyleName[lineStyle_]);
  // name of the source
  if ((id==ID_CONNECTION_SOURCE)&& isConnected_)
    return &(source_->name());
  // name of the target
  if ((id==ID_CONNECTION_TARGET)&& isConnected_)
    return &(target_->name());
  return NULL;
}

Here is the call graph for this function:


Member Data Documentation

Property ID to use for the line style property.

Definition at line 68 of file STK_Connection.h.

Referenced by getPropertyValue(), and isPropertySet().

Property ID to use for tjhe source property.

Definition at line 71 of file STK_Connection.h.

Referenced by getPropertyValue(), and isPropertySet().

Property ID to use for the target property.

Definition at line 74 of file STK_Connection.h.

Referenced by getPropertyValue(), and isPropertySet().

Descriptor of the line style property.

Definition at line 77 of file STK_Connection.h.

Descriptor of source property.

Definition at line 80 of file STK_Connection.h.

Descriptor of the target property.

Definition at line 83 of file STK_Connection.h.

const String STK::Connection::lineStyleName [static, private]
Initial value:
{
  "No Line",
  "Solid Line",
  "Dash Line",
  "Dot Line",
  "Dash Dot Line",
  "Dash Dot Dot Line",
  "Custom Dash Line"
}

Values of the line style Property.

Definition at line 86 of file STK_Connection.h.

Referenced by getPropertyValue().

True, if the connection is attached to its end-points.

Definition at line 90 of file STK_Connection.h.

Referenced by disconnect(), getPropertyValue(), isPropertySet(), and reconnect().

Default Line drawing style for this connection.

Definition at line 93 of file STK_Connection.h.

Referenced by getLineStyle(), getPropertyValue(), and setLineStyle().

Connection's source end-point.

Definition at line 96 of file STK_Connection.h.

Referenced by disconnect(), getPropertyValue(), getSource(), and reconnect().

Connection's target end-point.

Definition at line 99 of file STK_Connection.h.

Referenced by disconnect(), getPropertyValue(), getTarget(), and reconnect().


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