Salome HOME
Revert "Synchronize adm files"
[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 void InlineNode::accept(Visitor *visitor)
35 {
36   visitor->visitInlineNode(this);
37 }
38
39 //! Set the script (as a string) to execute
40 /*!
41  * \param script: script to execute
42  */
43 void InlineNode::setScript(const std::string& script) 
44
45   _script=script; 
46   modified();
47 }
48
49
50 InlineFuncNode::~InlineFuncNode()
51
52   if(_container)
53     _container->decrRef();
54 }
55
56 void InlineFuncNode::accept(Visitor *visitor)
57 {
58   visitor->visitInlineFuncNode(this);
59 }
60
61 void InlineFuncNode::setFname(const std::string& fname)
62 {
63   _fname=fname;
64   modified();
65 }
66
67 void InlineFuncNode::checkBasicConsistency() const throw(YACS::Exception)
68 {
69   InlineNode::checkBasicConsistency();
70   if(_fname.empty() )
71      {
72        string mess = "Function name is not defined";
73        throw Exception(mess);
74      }
75 }
76
77 void InlineNode::setExecutionMode(const std::string& mode)
78 {
79   if(mode == _mode)return;
80   if(mode == "local"||mode == "remote")
81     {
82       _mode=mode;
83       modified();
84     }
85 }
86
87 std::string InlineNode::getExecutionMode()
88 {
89   return _mode;
90 }
91
92 Container* InlineNode::getContainer()
93 {
94   return _container;
95 }
96
97 void InlineNode::setContainer(Container* cont)
98 {
99   if (cont == _container) return;
100   if(_container)
101     _container->decrRef();
102   _container=cont;
103   if(_container)
104     _container->incrRef();
105 }
106
107 void InlineNode::performDuplicationOfPlacement(const Node& other)
108 {
109   const InlineNode &otherC=*(dynamic_cast<const InlineNode *>(&other));
110   //if other has no container don't clone: this will not have one
111   if(otherC._container)
112     _container=otherC._container->clone();
113 }
114
115 bool InlineNode::isDeployable() const
116 {
117   if(_mode=="remote")
118     return true;
119   else
120     return false;
121 }
122