Salome HOME
9253406d1dd16adb4d806ad70a015ed630bc4791
[modules/yacs.git] / src / engine / InlineNode.hxx
1 #ifndef __INLINENODE_HXX__
2 #define __INLINENODE_HXX__
3
4 #include "ElementaryNode.hxx"
5 #include <string>
6
7 namespace YACS
8 {
9   namespace ENGINE
10   {
11 /*! \brief Class for calculation node (script) inlined (and executed) in the schema
12  *
13  * \ingroup Nodes
14  *
15  * This node is like a script. It has no state if it is executed several times.
16  * Each execution the string _script is executed within a clean context.
17  *
18  * \see ServiceNode
19  * \see ElementaryNode
20  */
21     class InlineNode : public ElementaryNode 
22     {
23     protected:
24       InlineNode(const InlineNode& other, ComposedNode *father)
25         :ElementaryNode(other,father),_script(other._script) { }
26       InlineNode(const std::string& name):ElementaryNode(name) { }
27     public:
28 //! Set the script (as a string) to execute
29 /*!
30  * \param script: script to execute
31  */
32       virtual void setScript(const std::string& script) { _script=script; }
33       virtual std::string getScript(){return _script;}
34
35 //! Return a new InlineNode node by making a copy of this node
36 /*!
37  * \param name: name of the new node
38  * \return the new node built by cloning.
39  */
40       virtual InlineNode* cloneNode(const std::string& name)
41       { throw Exception("Not implemented");};
42       virtual void accept(Visitor *visitor);
43       virtual ~InlineNode();
44     protected:
45       std::string _script;
46     };
47
48 /*! \brief Class for calculation node (function) inlined (and executed) in the schema
49  *
50  * \ingroup Nodes
51  *
52  * This node is like a function. It can have a state. The first time the node
53  * is executed, the string _script is executed in a clean context followed by the
54  * execution of the function _fname. Next times, the function _fname is executed 
55  * within the preserved context.
56  *
57  * \see ServiceNode
58  * \see ElementaryNode
59  */
60     class InlineFuncNode : public InlineNode
61     {
62     protected:
63       InlineFuncNode(const InlineFuncNode& other, ComposedNode *father)
64         :InlineNode(other,father),_fname(other._fname) { }
65       InlineFuncNode(const std::string& name):InlineNode(name) { }
66     public:
67 //! Set the function name to use in node execution
68 /*!
69  * \param fname: name of the function contained in the script to execute
70  */
71       virtual void setFname(const std::string& fname) { _fname=fname; }
72       virtual std::string getFname() { return _fname; }
73       void accept(Visitor *visitor);
74       virtual ~InlineFuncNode();
75     protected:
76       std::string _fname;
77     };
78   }
79 }
80
81 #endif