1 // Copyright (C) 2012-2015 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 __YACSEVALSEQANY_HXX__
22 #define __YACSEVALSEQANY_HXX__
24 #include "YACSEvalYFXExport.hxx"
25 #include "RefCounter.hxx"
26 #include "Exception.hxx"
42 YACSEVALYFX_EXPORT static YACSEvalSeqAny *BuildEmptyFromType(const std::string& dataType);
43 YACSEVALYFX_EXPORT virtual std::size_t size() const = 0;
44 YACSEVALYFX_EXPORT virtual std::string getTypeOfConstitutingElements() const = 0;
45 YACSEVALYFX_EXPORT virtual YACSEvalSeqAny *copy() const = 0;
46 YACSEVALYFX_EXPORT virtual void initialize(YACS::ENGINE::InputPyPort *p) const = 0;
47 YACSEVALYFX_EXPORT virtual ~YACSEvalSeqAny() { }
51 class YACSEvalSeqAnyInternal : public YACS::ENGINE::RefCounter
54 static YACSEvalSeqAnyInternal<T> *New(std::vector<T> *arr) { return new YACSEvalSeqAnyInternal(arr); }
55 std::size_t size() const;
56 T operator[](const std::size_t i) const { if(_arr) return (*_arr)[i]; else throw YACS::Exception("YACSEvalSeqAnyInternal[] : internal pointer is null !"); }
57 std::vector<T> *getInternal() const { return _arr; }
59 ~YACSEvalSeqAnyInternal() { delete _arr; }
60 YACSEvalSeqAnyInternal(std::vector<T> *arr):_arr(arr) { }
65 class YACSEvalSeqAnyDouble : public YACSEvalSeqAny
68 YACSEVALYFX_EXPORT std::size_t size() const { return _arr->size(); }
69 YACSEVALYFX_EXPORT ~YACSEvalSeqAnyDouble() { if(_arr) _arr->decrRef(); }
70 YACSEVALYFX_EXPORT YACSEvalSeqAnyDouble(const std::vector<double>& arr);
71 YACSEVALYFX_EXPORT YACSEvalSeqAnyDouble(const YACSEvalSeqAnyDouble& other);
72 YACSEVALYFX_EXPORT YACSEvalSeqAnyDouble();
73 YACSEVALYFX_EXPORT std::string getTypeOfConstitutingElements() const;
74 YACSEVALYFX_EXPORT YACSEvalSeqAnyDouble *copy() const;
75 YACSEVALYFX_EXPORT void initialize(YACS::ENGINE::InputPyPort *p) const;
76 YACSEVALYFX_EXPORT std::vector<double> *getInternal() const;
78 YACSEvalSeqAnyInternal<double> *_arr;
81 class YACSEvalSeqAnyInt : public YACSEvalSeqAny
84 YACSEVALYFX_EXPORT std::size_t size() const { return _arr->size(); }
85 YACSEVALYFX_EXPORT ~YACSEvalSeqAnyInt() { if(_arr) _arr->decrRef(); }
86 YACSEVALYFX_EXPORT YACSEvalSeqAnyInt(const std::vector<int>& arr);
87 YACSEVALYFX_EXPORT YACSEvalSeqAnyInt(const YACSEvalSeqAnyInt& other);
88 YACSEVALYFX_EXPORT YACSEvalSeqAnyInt();
89 YACSEVALYFX_EXPORT std::string getTypeOfConstitutingElements() const;
90 YACSEVALYFX_EXPORT YACSEvalSeqAnyInt *copy() const;
91 YACSEVALYFX_EXPORT void initialize(YACS::ENGINE::InputPyPort *p) const;
92 YACSEVALYFX_EXPORT std::vector<int> *getInternal() const;
94 YACSEvalSeqAnyInternal<int> *_arr;