]> SALOME platform Git repositories - modules/yacs.git/blob - src/engine/InlineNode.cxx
Salome HOME
Ready to update Executor to take into account of the new type of containers.
[modules/yacs.git] / src / engine / InlineNode.cxx
1 // Copyright (C) 2006-2014  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 #include "InlineNode.hxx"
21 #include "Visitor.hxx"
22 #include "Container.hxx"
23 #include <iostream>
24
25 #define _DEVDEBUG_
26 #include "YacsTrace.hxx"
27
28 using namespace YACS::ENGINE;
29 using namespace std;
30
31
32 InlineNode::~InlineNode()
33 {
34   if(_container)
35     _container->decrRef();
36 }
37
38 void InlineNode::accept(Visitor *visitor)
39 {
40   visitor->visitInlineNode(this);
41 }
42
43 //! Set the script (as a string) to execute
44 /*!
45  * \param script: script to execute
46  */
47 void InlineNode::setScript(const std::string& script) 
48
49   _script=script; 
50   modified();
51 }
52
53
54 InlineFuncNode::~InlineFuncNode()
55 {
56 }
57
58 void InlineFuncNode::accept(Visitor *visitor)
59 {
60   visitor->visitInlineFuncNode(this);
61 }
62
63 /*!
64  * \param fname: name of the function contained in the script to execute
65  */
66 void InlineFuncNode::setFname(const std::string& fname)
67 {
68   _fname=fname;
69   modified();
70 }
71
72 void InlineFuncNode::checkBasicConsistency() const throw(YACS::Exception)
73 {
74   InlineNode::checkBasicConsistency();
75   if(_fname.empty() )
76      {
77        string mess = "Function name is not defined";
78        throw Exception(mess);
79      }
80 }
81
82 void InlineNode::setExecutionMode(const std::string& mode)
83 {
84   if(mode == _mode)return;
85   if(mode == "local"||mode == "remote")
86     {
87       _mode=mode;
88       modified();
89     }
90 }
91
92 std::string InlineNode::getExecutionMode()
93 {
94   return _mode;
95 }
96
97 Container* InlineNode::getContainer()
98 {
99   return _container;
100 }
101
102 void InlineNode::setContainer(Container* cont)
103 {
104   if (cont == _container) return;
105   if(_container)
106     _container->decrRef();
107   _container=cont;
108   if(_container)
109     _container->incrRef();
110 }
111
112 void InlineNode::performDuplicationOfPlacement(const Node& other)
113 {
114   const InlineNode &otherC=*(dynamic_cast<const InlineNode *>(&other));
115   //if other has no container don't clone: this will not have one
116   if(otherC._container)
117     _container=otherC._container->clone();
118 }
119
120 bool InlineNode::isDeployable() const
121 {
122   if(_mode=="remote")
123     return true;
124   else
125     return false;
126 }
127