Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

loopcontrol.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                           loopcontrol.h  -  description
00003                              -------------------
00004     begin                : Wed May 8 2002
00005     copyright            : (C) 2002 by Peter Haase
00006     email                : mail@p-haase.de
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This library is free software; you can redistribute it and/or         *
00012  *   modify it under the terms of the GNU Lesser General Public            *
00013  *   License as published by the Free Software Foundation; either          *
00014  *   version 2.1 of the License, or (at your option) any later version.    *
00015  *                                                                         *
00016  *   This library is distributed in the hope that it will be useful,       *
00017  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00018  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00019  *   Lesser General Public License for more details.                       *
00020  *                                                                         *
00021  *   You should have received a copy of the GNU Lesser General Public      *
00022  *   License along with this library; if not, write to the Free Software   *
00023  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston,                 *
00024  *   MA  02111-1307  USA                                                   *
00025  *                                                                         *
00026  ***************************************************************************/
00027 
00044 #ifndef SYSTEM_LOOP_CONTROL_HEADER
00045 #define SYSTEM_LOOP_CONTROL_HEADER
00046 
00047 
00048 #include <string>
00049 #include <simthetic/phbib.h>
00050 
00051 
00052 namespace simth
00053 {
00054 
00055 class ControlInterface;
00056 template<class T> class  ControlInterfaceT;
00057 class ControlInterfaceVoid;
00058 
00059 
00071 class LoopControl
00072 {
00073 
00074   public:
00075 
00077     LoopControl() {};
00079     virtual ~LoopControl() {};
00080 
00085     virtual const std::string& name() const = 0;
00086 
00089     virtual std::string currentIteration() const = 0; 
00090 
00094     virtual std::string lastIteration() const = 0; 
00095 
00105     virtual bool nextIteration() = 0;
00106 
00113     virtual void connectControlInterface(ControlInterface* interface) = 0;
00114 
00119     virtual bool reachedEnd() = 0;
00120 
00124     virtual void reset() = 0;
00125 };
00126 
00127 
00135 class CounterLoopControl : public LoopControl
00136 {
00137     std::string name_;
00138 
00139 
00140     int numLoops;
00141     int currLoops;
00142 
00143     checkedVector<ControlInterfaceVoid*> interfaces;
00144 
00145   public:
00150     CounterLoopControl(const std::string& name, int numLoops);
00151     virtual ~CounterLoopControl();
00152 
00153     const std::string& name() const {return name_;}
00154 
00157     virtual std::string currentIteration() const; 
00158 
00162     virtual std::string lastIteration() const; 
00163 
00164     virtual bool nextIteration();
00165 
00166     virtual void connectControlInterface(ControlInterface* interface);
00167 
00168     virtual bool reachedEnd();
00169 
00170     virtual void reset();
00171 };
00172 
00173 
00184 template<class T>
00185 class LinearLoopControl : public LoopControl
00186 {
00187 
00188     std::string name_;
00189 
00190     T start_;
00191     T end_;
00192     T incr;
00193     T value_;
00194 
00195     checkedVector<ControlInterfaceT<T>*> interfaces;
00196 
00197 
00198   public:
00199 
00207     LinearLoopControl(const std::string& name, T start, T end, T increment);
00208     virtual ~LinearLoopControl();
00209 
00210     const std::string& name() const {return name_;}
00211 
00214     virtual std::string currentIteration() const; 
00215 
00219     virtual std::string lastIteration() const; 
00220 
00221     T value() const {return value_;}
00222 
00223     virtual bool nextIteration();
00224 
00225     virtual void connectControlInterface(ControlInterface* interface);
00226 
00227     virtual bool reachedEnd();
00228 
00229     virtual void reset();
00230 };
00231 
00232 } // namespace
00233 
00234 #endif
00235 

Generated on Mon Apr 24 21:19:19 2006 for simthetic by  doxygen 1.4.1