Diana
0.8.3
|
00001 /* ----------------------------------------------------------------------------- 00002 * Diana process modelling, simulation and analysis software 00003 * Copyright (c) 2005, Michael Krasnyk 00004 * All rights reserved. 00005 * 00006 * This file is a part of Diana process modelling, simulation and analysis software 00007 * 00008 * Diana is free software; you can redistribute it and/or modify it 00009 * under the terms of the GNU General Public License as published 00010 * by the Free Software Foundation (see accompanying file LICENSE) 00011 * ----------------------------------------------------------------------------- 00012 * $Id: CapeModel.hpp 8160 2009-03-16 18:36:30Z miha $ 00013 * ----------------------------------------------------------------------------- 00014 * Description: 00015 */ 00016 00017 #ifndef CAPE_MODEL_HPP 00018 #define CAPE_MODEL_HPP 00019 00020 #include "CapeTypes.hpp" 00021 #include "CapeException.hpp" 00022 #include "CapeMatrix.hpp" 00023 #include "CapeESO.hpp" 00024 00025 namespace Numeric{ 00026 00027 namespace Solvers { 00028 00032 namespace Model { 00033 00037 enum CapeModelType{ 00038 CAPE_CONTINUOUS, 00039 CAPE_HIERARCHICAL, 00040 CAPE_AGGREGATE 00041 }; 00042 00044 enum CapeEventType{ 00045 CAPE_BASIC, 00046 CAPE_COMPOSITE, 00047 CAPE_BINARY, 00048 CAPE_UNARY 00049 }; 00050 00052 enum CapeEventInfoKind{ 00053 CAPE_EXTERNAL, 00054 CAPE_INTERNAL 00055 }; 00056 00058 enum CapeLogicalRelation{ 00059 CAPE_GEQ, 00060 CAPE_LEQ, 00061 CAPE_GT, 00062 CAPE_LT 00063 }; 00064 00066 enum CapeLogicalOperator{ 00067 CAPE_AND, 00068 CAPE_OR, 00069 CAPE_NOT 00070 }; 00071 00073 typedef std::vector<CapeModelType> CapeArrayModelType; 00075 typedef std::vector<CapeEventType> CapeArrayEventType; 00077 typedef std::vector<CapeEventInfoKind> CapeArrayEventInfoKind; 00079 typedef std::vector<CapeLogicalRelation> CapeArrayLogicalRelation; 00081 typedef std::vector<CapeLogicalOperator> CapeArrayLogicalOperator; 00082 00083 // Foward declaration of interfaces 00084 class ICapeNumericModelManager; 00085 class ICapeNumericModel; 00086 class ICapeNumericContinuousModel; 00087 class ICapeNumericHierarchicalModel; 00088 class ICapeNumericAggregateModel; 00089 class ICapeNumericSTN; 00090 class ICapeNumericEvent; 00091 class ICapeNumericBasicEvent; 00092 class ICapeNumericCompositeEvent; 00093 class ICapeNumericBinaryEvent; 00094 class ICapeNumericUnaryEvent; 00095 class ICapeNumericEventInfo; 00096 class ICapeNumericExternalEventInfo; 00097 class ICapeNumericInternalEventInfo; 00098 00099 // Interface sequence 00101 typedef std::vector<ICapeNumericModel*> CapeArrayNumericModel; 00103 typedef std::vector<ICapeNumericContinuousModel*> CapeArrayNumericContinuousModel; 00105 typedef std::vector<ICapeNumericHierarchicalModel*> CapeArrayNumericHierarchicalModel; 00107 typedef std::vector<ICapeNumericAggregateModel*> CapeArrayNumericAggregateModel; 00109 typedef std::vector<ICapeNumericSTN*> CapeArrayNumericSTN; 00111 typedef std::vector<ICapeNumericEvent*> CapeArrayNumericEvent; 00113 typedef std::vector<ICapeNumericBasicEvent*> CapeArrayNumericBasicEvent; 00115 typedef std::vector<ICapeNumericCompositeEvent*> CapeArrayNumericCompositeEvent; 00117 typedef std::vector<ICapeNumericBinaryEvent*> CapeArrayNumericBinaryEvent; 00119 typedef std::vector<ICapeNumericUnaryEvent*> CapeArrayNumericUnaryEvent; 00121 typedef std::vector<ICapeNumericEventInfo*> CapeArrayNumericEventInfo; 00123 typedef std::vector<ICapeNumericExternalEventInfo*> CapeArrayNumericExternalEventInfo; 00125 typedef std::vector<ICapeNumericInternalEventInfo*> CapeArrayNumericInternalEventInfo; 00126 00127 00131 class ICapeNumericModelManager { 00132 public: 00140 virtual ICapeNumericModel* CreateModel(CapeModelType typeOfTheModel, 00141 Common::Types::CapeString strLibraryName=Common::Types::CapeStringUNDEFINED) 00142 throw (Common::Error::ECapeUnknown, Common::Error::ECapeInvalidArgument, 00143 Common::Error::ECapeOutOfBounds, Common::Error::ECapeOutOfResources, 00144 Common::Error::ECapeFailedInitialisation) = 0; 00145 }; 00146 00147 00149 class ICapeNumericModel : public Common::Identification::ICapeIdentification, 00150 public Common::Utilities::ICapeUtilities { 00151 #ifndef SWIG 00152 00153 friend std::ostream& operator<<(std::ostream& out_file, const ICapeNumericModel& model); 00154 #endif 00155 public: 00156 #ifndef SWIG 00157 virtual ~ICapeNumericModel(){}; 00158 #endif 00159 00167 virtual Common::Types::CapeLong SetVariablesIndex(Common::Types::CapeArrayLong varIndices) 00168 throw (Common::Error::ECapeUnknown, Common::Error::ECapeInvalidArgument, 00169 Common::Error::ECapeOutOfBounds, Common::Error::ECapeNoImpl) = 0; 00174 virtual void SetActiveESO(Eso::ICapeNumericESO* theActiveESO) 00175 throw (Common::Error::ECapeUnknown, Common::Error::ECapeInvalidArgument, 00176 Common::Error::ECapeSolvingError, Common::Error::ECapeBadInvOrder) = 0; 00177 00179 virtual Eso::ICapeNumericESO* GetActiveESO() 00180 throw (Common::Error::ECapeUnknown, Common::Error::ECapeBadInvOrder) = 0; 00181 00184 virtual void SetCommonESO(Eso::ICapeNumericESO* anESO) 00185 throw (Common::Error::ECapeUnknown, Common::Error::ECapeInvalidArgument, 00186 Common::Error::ECapeNoImpl) = 0; 00187 00189 virtual Eso::ICapeNumericESO* GetCommonESO() 00190 throw (Common::Error::ECapeUnknown, Common::Error::ECapeBadInvOrder, 00191 Common::Error::ECapeNoImpl) = 0; 00192 00196 virtual ICapeNumericExternalEventInfo* AddExternalEvent(ICapeNumericEvent* anEvent) 00197 throw (Common::Error::ECapeUnknown, Common::Error::ECapeInvalidArgument, 00198 Common::Error::ECapeBadInvOrder, Common::Error::ECapeNoImpl) = 0; 00199 00200 }; 00201 00203 class ICapeNumericContinuousModel : public ICapeNumericModel { 00204 #ifndef SWIG 00205 00206 friend std::ostream& operator<<(std::ostream& out_file, const ICapeNumericContinuousModel& model); 00207 #endif 00208 }; 00209 00212 class ICapeNumericHierarchicalModel : public ICapeNumericModel { 00213 #ifndef SWIG 00214 00215 friend std::ostream& operator<<(std::ostream& out_file, const ICapeNumericHierarchicalModel& model); 00216 #endif 00217 public: 00220 virtual CapeArrayNumericSTN GetSTNList() 00221 throw (Common::Error::ECapeUnknown, Common::Error::ECapeBadInvOrder) = 0; 00222 }; 00223 00230 class ICapeNumericAggregateModel : public ICapeNumericModel { 00231 #ifndef SWIG 00232 00233 friend std::ostream& operator<<(std::ostream& out_file, const ICapeNumericAggregateModel& model); 00234 #endif 00235 public: 00237 virtual CapeArrayNumericModel GetModelList() 00238 throw (Common::Error::ECapeUnknown, Common::Error::ECapeBadInvOrder) = 0; 00239 00246 virtual void SetConnectionEquation(ICapeNumericModel* inputModel, Common::Types::CapeLong inputIndex, 00247 ICapeNumericModel* outputModel, Common::Types::CapeLong outputIndex) 00248 throw (Common::Error::ECapeUnknown, Common::Error::ECapeInvalidArgument, 00249 Common::Error::ECapeBadInvOrder, Common::Error::ECapeOutOfBounds) = 0; 00250 }; 00251 00252 00254 class ICapeNumericSTN { 00255 public: 00260 virtual void SetCurrentState(const Common::Types::CapeString& theStateName) 00261 throw (Common::Error::ECapeUnknown, Common::Error::ECapeInvalidArgument, 00262 Common::Error::ECapeBadInvOrder, Common::Error::ECapeOutOfBounds) = 0; 00263 00265 virtual Common::Types::CapeString GetCurrentState() 00266 throw (Common::Error::ECapeUnknown, Common::Error::ECapeBadInvOrder) = 0; 00267 00269 virtual ICapeNumericModel* GetParentModel() 00270 throw (Common::Error::ECapeUnknown, Common::Error::ECapeBadInvOrder) = 0; 00271 00273 virtual CapeArrayNumericInternalEventInfo GetPossibleTransitions() 00274 throw (Common::Error::ECapeUnknown, Common::Error::ECapeBadInvOrder) = 0; 00275 00282 virtual Common::Types::CapeDouble GetStateTransitions(const Common::Types::CapeString& fromState, CapeArrayNumericEventInfo& eventList, 00283 Common::Types::CapeArrayString& stateList) 00284 throw (Common::Error::ECapeUnknown, Common::Error::ECapeInvalidArgument, 00285 Common::Error::ECapeBadInvOrder, Common::Error::ECapeOutOfBounds) = 0; 00286 00288 virtual Common::Types::CapeArrayString GetStateList() 00289 throw (Common::Error::ECapeUnknown, Common::Error::ECapeBadInvOrder) = 0; 00290 00292 virtual ICapeNumericModel* GetStateModel(const Common::Types::CapeString& stateName) 00293 throw (Common::Error::ECapeUnknown, Common::Error::ECapeInvalidArgument, 00294 Common::Error::ECapeBadInvOrder, Common::Error::ECapeOutOfBounds) = 0; 00295 00299 virtual Common::Types::CapeString MoveToNextState(ICapeNumericEventInfo* firedEvent) 00300 throw (Common::Error::ECapeUnknown, Common::Error::ECapeInvalidArgument, 00301 Common::Error::ECapeBadInvOrder, Common::Error::ECapeOutOfBounds) = 0; 00302 }; 00303 00321 class ICapeNumericEvent { 00322 public: 00324 virtual Common::Types::CapeBoolean Eval() 00325 throw (Common::Error::ECapeUnknown, Common::Error::ECapeBadInvOrder) = 0; 00326 00330 virtual CapeEventType QueryType() throw (Common::Error::ECapeUnknown) = 0; 00331 }; 00332 00339 class ICapeNumericBasicEvent : public ICapeNumericEvent { 00340 public: 00342 virtual Common::Types::CapeLong GetVariable() 00343 throw (Common::Error::ECapeUnknown) = 0; 00344 00348 virtual CapeLogicalRelation GetLogicalRelation() 00349 throw (Common::Error::ECapeUnknown) = 0; 00350 00353 virtual Common::Types::CapeDouble GetValue() 00354 throw (Common::Error::ECapeUnknown) = 0; 00355 }; 00356 00365 class ICapeNumericCompositeEvent : public ICapeNumericEvent { 00366 public: 00368 virtual ICapeNumericEvent* GetRightOperand() 00369 throw (Common::Error::ECapeUnknown) = 0; 00372 virtual CapeLogicalOperator* GetLogicalOperator() 00373 throw (Common::Error::ECapeUnknown) = 0; 00374 }; 00375 00380 class ICapeNumericBinaryEvent : public ICapeNumericCompositeEvent { 00381 public: 00383 virtual ICapeNumericEvent* GetLeftOperand() 00384 throw (Common::Error::ECapeUnknown) = 0; 00385 }; 00386 00392 class ICapeNumericUnaryEvent : public ICapeNumericCompositeEvent { 00393 }; 00394 00409 class ICapeNumericEventInfo { 00410 public: 00412 virtual CapeEventInfoKind QueryKind() 00413 throw (Common::Error::ECapeUnknown) = 0; 00414 00416 virtual ICapeNumericEvent* GetSubEvent() 00417 throw (Common::Error::ECapeUnknown) = 0; 00418 00420 virtual ICapeNumericEvent* GetEvent() 00421 throw (Common::Error::ECapeUnknown) = 0; 00422 }; 00423 00429 class ICapeNumericExternalEventInfo : public ICapeNumericEventInfo { 00430 }; 00431 00441 class ICapeNumericInternalEventInfo : public ICapeNumericEventInfo { 00442 public: 00445 virtual ICapeNumericSTN* GetSTN() 00446 throw (Common::Error::ECapeUnknown) = 0; 00447 00451 virtual Common::Types::CapeString GetToState() 00452 throw (Common::Error::ECapeUnknown) = 0; 00453 }; 00454 }; 00455 }; 00456 }; 00457 00458 #endif // CAPE_MODEL_HPP