STK++ 1.0
STK_Connection.h
Go to the documentation of this file.
00001 /*--------------------------------------------------------------------*/
00002 /*     Copyright (C) 2004-2007  Serge Iovleff
00003 
00004  This program is free software; you can redistribute it and/or modify
00005  it under the terms of the GNU Lesser General Public License as
00006  published by the Free Software Foundation; either version 2 of the
00007  License, or (at your option) any later version.
00008 
00009  This program is distributed in the hope that it will be useful,
00010  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  GNU Lesser General Public License for more details.
00013 
00014  You should have received a copy of the GNU Lesser General Public
00015  License along with this program; if not, write to the
00016  Free Software Foundation, Inc.,
00017  59 Temple Place,
00018  Suite 330,
00019  Boston, MA 02111-1307
00020  USA
00021 
00022  Contact : Serge.Iovleff@stkpp.org
00023  */
00024 
00025 /*
00026  * Project:  stkpp::gui
00027  * created on: 2 oct. 2009
00028  * Purpose:  A connection between two distinct steps.
00029  * Author:   iovleff, serge.iovleff@stkpp.org
00030  **/
00031 
00036 #ifndef STK_CONNECTION_H
00037 #define STK_CONNECTION_H
00038 
00039 #include "../../../projects/STKernel/include/STK_String.h"
00040 
00041 #include "STK_IPropertySource.h"
00042 
00043 namespace STK
00044 {
00045 
00046 class IStep;
00047 
00053 class Connection: public STK::IPropertySource
00054 {
00055   public:
00056     enum PenStyle { // pen style
00057         NoPen,
00058         SolidLine,
00059         DashLine,
00060         DotLine,
00061         DashDotLine,
00062         DashDotDotLine,
00063         CustomDashLine
00064     };
00065 
00066   private:
00068     static const String ID_CONNECTION_LINESTYLE;
00069 
00071     static const String ID_CONNECTION_SOURCE;
00072 
00074     static const String ID_CONNECTION_TARGET;
00075 
00077     static const PropertyDescriptor lineStyleDescriptor_;
00078 
00080     static const PropertyDescriptor sourceDescriptor_;
00081 
00083     static const PropertyDescriptor targetDescriptor_;
00084 
00086     static const String lineStyleName[];
00087 
00088   protected:
00090     bool isConnected_;
00091 
00093     PenStyle lineStyle_;
00094 
00096     IStep* source_;
00097 
00099     IStep* target_;
00100 
00101   public:
00108     Connection( IStep* source
00109               , IStep* target
00110               , const PenStyle& lineStyle = SolidLine
00111               );
00112 
00114     virtual ~Connection();
00115 
00120     const PenStyle& getLineStyle() const;
00121 
00125     IStep* getSource() const;
00126 
00130     IStep* getTarget() const;
00131 
00138     void setLineStyle( const PenStyle& lineStyle);
00139 
00143     void disconnect();
00144 
00149     void reconnect();
00150 
00159     void reconnect( IStep* newSource, IStep* newTarget);
00160 
00168     virtual bool isPropertySet(String const& id) const;
00169 
00177     virtual const String* getPropertyValue(String const& id) const;
00178 };
00179 
00180 }
00181 
00182 #endif /* STK_CONNECTION_H */