1 // Copyright (C) 2012-2016 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (EDF R&D)
21 #ifndef __YACSEVALPORT_HXX__
22 #define __YACSEVALPORT_HXX__
24 #include "YACSEvalYFXExport.hxx"
45 YACSEVALYFX_EXPORT virtual ~YACSEvalAny() { }
46 YACSEVALYFX_EXPORT virtual std::string getTypeOfData() const = 0;
47 YACSEVALYFX_EXPORT virtual int toInt() const = 0;
48 YACSEVALYFX_EXPORT virtual double toDouble() const = 0;
49 YACSEVALYFX_EXPORT virtual YACSEvalAny *deepCpy() const = 0;
52 class YACSEvalAnyDouble : public YACSEvalAny
55 YACSEVALYFX_EXPORT YACSEvalAnyDouble(double val):_v(val) { }
56 YACSEVALYFX_EXPORT std::string getTypeOfData() const { return std::string(TYPE_REPR); }
57 YACSEVALYFX_EXPORT int toInt() const;
58 YACSEVALYFX_EXPORT double toDouble() const;
59 YACSEVALYFX_EXPORT YACSEvalAnyDouble *deepCpy() const;
60 YACSEVALYFX_EXPORT ~YACSEvalAnyDouble() { }
64 YACSEVALYFX_EXPORT static const char TYPE_REPR[];
67 class YACSEvalAnyInt : public YACSEvalAny
70 YACSEVALYFX_EXPORT YACSEvalAnyInt(int val):_v(val) { }
71 YACSEVALYFX_EXPORT std::string getTypeOfData() const { return std::string(TYPE_REPR); }
72 YACSEVALYFX_EXPORT int toInt() const;
73 YACSEVALYFX_EXPORT double toDouble() const;
74 YACSEVALYFX_EXPORT YACSEvalAnyInt *deepCpy() const;
75 YACSEVALYFX_EXPORT ~YACSEvalAnyInt() { }
79 YACSEVALYFX_EXPORT static const char TYPE_REPR[];
85 YACSEVALYFX_EXPORT virtual std::string getTypeOfData() const = 0;
86 YACSEVALYFX_EXPORT virtual ~YACSEvalPort() { }
88 YACSEVALYFX_EXPORT static bool IsInputPortPublishable(const YACS::ENGINE::InputPort *port);
89 YACSEVALYFX_EXPORT static bool IsOutputPortPublishable(const YACS::ENGINE::OutputPort *port);
91 YACSEVALYFX_EXPORT static std::string GetTypeOfData(const YACS::ENGINE::DataPort *port);
94 class YACSEvalInputPort : public YACSEvalPort
97 YACSEVALYFX_EXPORT YACSEvalInputPort(YACS::ENGINE::InputPort *ptr);
98 YACSEVALYFX_EXPORT std::string getName() const;
99 YACSEVALYFX_EXPORT std::string getTypeOfData() const;
100 YACSEVALYFX_EXPORT bool isOKForLock() const;
101 YACSEVALYFX_EXPORT bool isLocked() const;
103 YACSEVALYFX_EXPORT bool hasDefaultValueDefined() const;
104 YACSEVALYFX_EXPORT YACSEvalAny *getDefaultValueDefined() const;
105 YACSEVALYFX_EXPORT void setDefaultValue(const YACSEvalAny *parameter);
106 YACSEVALYFX_EXPORT void setSequenceOfValuesToEval(const YACSEvalSeqAny* vals);
107 YACSEVALYFX_EXPORT bool hasSequenceOfValuesToEval() const;
108 YACSEVALYFX_EXPORT YACSEvalSeqAny *getSequenceOfValuesToEval() const { return _mySeq; }
109 YACSEVALYFX_EXPORT bool isRandomVar() const { return _isRandom; }
110 YACSEVALYFX_EXPORT void declareRandomnessStatus(bool isRandom);
112 YACSEVALYFX_EXPORT YACS::ENGINE::InputPort *getUndergroundPtr() const { return _ptr; }
113 YACSEVALYFX_EXPORT std::size_t initializeUndergroundWithSeq() const;
115 YACSEVALYFX_EXPORT virtual ~YACSEvalInputPort();
116 void lock() const { _isLocked=true; }
117 void unlock() const { _isLocked=false; _isRandom=false; }
118 void setUndergroundPortToBeSet(YACS::ENGINE::InputPyPort *p) const;
120 YACSEvalAny *convertFromInternalAnyToExternal(YACS::ENGINE::Any *data) const;
121 void checkForNonConstMethod() const;
123 YACS::ENGINE::InputPort * _ptr;
124 YACSEvalSeqAny *_mySeq;
125 mutable bool _isRandom;
126 mutable bool _isLocked;
127 mutable YACS::ENGINE::InputPyPort *_undergroundPort;
130 class YACSEvalOutputPort : public YACSEvalPort
133 YACSEVALYFX_EXPORT YACSEvalOutputPort(YACS::ENGINE::OutputPort *ptr);
134 YACSEVALYFX_EXPORT std::string getName() const;
135 YACSEVALYFX_EXPORT std::string getTypeOfData() const;
136 YACSEVALYFX_EXPORT bool setQOfInterestStatus(bool newStatus) { _isQOfInt=newStatus; return _isQOfInt; }
137 YACSEVALYFX_EXPORT bool isQOfInterest() const { return _isQOfInt; }
139 YACSEVALYFX_EXPORT YACS::ENGINE::OutputPort *getUndergroundPtr() const { return _ptr; }
142 YACS::ENGINE::OutputPort * _ptr;