Salome HOME
f7d4245be9629debf7262934fd8445f2ee832097
[modules/yacs.git] / src / engine / InlineNode.hxx
1 // Copyright (C) 2006-2022  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef __INLINENODE_HXX__
21 #define __INLINENODE_HXX__
22
23 #include "YACSlibEngineExport.hxx"
24 #include "ElementaryNode.hxx"
25 #include <string>
26
27 namespace YACS
28 {
29   namespace ENGINE
30   {
31     class Container;
32
33 /*! \brief Class for calculation node (script) inlined (and executed) in the schema
34  *
35  * \ingroup Nodes
36  *
37  * This node is like a script. It has no state if it is executed several times.
38  * Each execution the string _script is executed within a clean context.
39  *
40  * \see ServiceNode
41  * \see ElementaryNode
42  */
43     class YACSLIBENGINE_EXPORT InlineNode : public ElementaryNode 
44     {
45     protected:
46       InlineNode(const InlineNode& other, ComposedNode *father)
47         :ElementaryNode(other,father),_script(other._script),_mode(other._mode),_container(0) { }
48       InlineNode(const std::string& name):ElementaryNode(name),_mode(LOCAL_STR),_container(0) { }
49     public:
50       virtual void setScript(const std::string& script);
51       virtual std::string getScript(){return _script;}
52
53 //! Return a new InlineNode node by making a copy of this node
54 /*!
55  * \param name: name of the new node
56  * \return the new node built by cloning.
57  */
58       virtual InlineNode* cloneNode(const std::string& name)
59       { throw Exception("Not implemented");};
60       virtual void accept(Visitor *visitor);
61       virtual ~InlineNode();
62       virtual std::string typeName() {return "YACS__ENGINE__InlineNode";}
63       virtual void setExecutionMode(const std::string& mode);
64       virtual std::string getExecutionMode();
65       virtual void setContainer(Container* container);
66       virtual Container* getContainer();
67       void performDuplicationOfPlacement(const Node& other);
68       void performShallowDuplicationOfPlacement(const Node& other);
69       bool isDeployable() const;
70       int getMaxLevelOfParallelism() const;
71     public:
72       static const char LOCAL_STR[];
73       static const char REMOTE_STR[];
74     protected:
75       std::string _script;
76       std::string _mode;
77       Container* _container;
78     };
79
80 /*! \brief Class for calculation node (function) inlined (and executed) in the schema
81  *
82  * \ingroup Nodes
83  *
84  * This node is like a function. It can have a state. The first time the node
85  * is executed, the string _script is executed in a clean context followed by the
86  * execution of the function _fname. Next times, the function _fname is executed 
87  * within the preserved context.
88  *
89  * \see ServiceNode
90  * \see ElementaryNode
91  */
92     class YACSLIBENGINE_EXPORT InlineFuncNode : public InlineNode
93     {
94     protected:
95       InlineFuncNode(const InlineFuncNode& other, ComposedNode *father)
96         :InlineNode(other,father),_fname(other._fname) { }
97       InlineFuncNode(const std::string& name):InlineNode(name) { }
98     public:
99       //! Set the function name to use in node execution
100       virtual void setFname(const std::string& fname);
101       virtual std::string getFname() { return _fname; }
102       void accept(Visitor *visitor);
103       virtual ~InlineFuncNode();
104       virtual std::string typeName() { return "YACS__ENGINE__InlineFuncNode"; }
105       virtual void checkBasicConsistency() const ;
106     protected:
107       std::string _fname;
108     };
109   }
110 }
111
112 #endif