Version: 9.15.0
InlineNode.cxx
Go to the documentation of this file.
1 // Copyright (C) 2006-2025 CEA, EDF
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 const char InlineNode::LOCAL_STR[]="local";
32 
33 const char InlineNode::REMOTE_STR[]="remote";
34 
36 {
37  if(_container)
38  _container->decrRef();
39 }
40 
42 {
43  visitor->visitInlineNode(this);
44 }
45 
47 
50 void InlineNode::setScript(const std::string& script)
51 {
52  _script=script;
53  modified();
54 }
55 
56 
58 {
59 }
60 
62 {
63  visitor->visitInlineFuncNode(this);
64 }
65 
69 void InlineFuncNode::setFname(const std::string& fname)
70 {
71  _fname=fname;
72  modified();
73 }
74 
76 {
78  if(_fname.empty() )
79  {
80  string mess = "Function name is not defined";
81  throw Exception(mess);
82  }
83 }
84 
85 void InlineNode::setExecutionMode(const std::string& mode)
86 {
87  if(mode == _mode)return;
88  if(mode == LOCAL_STR || mode == REMOTE_STR)
89  {
90  _mode=mode;
91  modified();
92  }
93 }
94 
96 {
97  return _mode;
98 }
99 
101 {
102  return _container;
103 }
104 
106 {
107  if (cont == _container) return;
108  if(_container)
109  _container->decrRef();
110  _container=cont;
111  if(_container)
112  _container->incrRef();
113 }
114 
116 {
117  const InlineNode &otherC=*(dynamic_cast<const InlineNode *>(&other));
118  //if other has no container don't clone: this will not have one
119  if(otherC._container)
120  _container=otherC._container->clone();
121 }
122 
124 {
125  const InlineNode &otherC=*(dynamic_cast<const InlineNode *>(&other));
126  //if other has no container don't clone: this will not have one
127  if(otherC._container)
128  {
129  _container=otherC._container;
130  _container->incrRef();
131  }
132 }
133 
135 {
136  if(_mode==REMOTE_STR)
137  return true;
138  else
139  return false;
140 }
141 
143 {
144  if(!isDeployable())
145  return 1;
146  if(!_container)
147  return 1;
148  std::map<std::string,std::string> props(_container->getProperties());
149  std::map<std::string,std::string>::iterator it(props.find(std::string("nb_proc_per_node")));
150  if(it==props.end())
151  return 1;
152  if((*it).second.empty())
153  return 1;
154  std::istringstream iss((*it).second);
155  int ret(1); iss >> ret;
156  return ret;
157 }
virtual Container * clone() const =0
WARNING ! clone behaviour MUST be in coherence with what is returned by isAttachedOnCloning() method
virtual void checkBasicConsistency() const
virtual void setFname(const std::string &fname)
Set the function name to use in node execution.
Definition: InlineNode.cxx:69
virtual void checkBasicConsistency() const
Definition: InlineNode.cxx:75
void accept(Visitor *visitor)
Definition: InlineNode.cxx:61
Class for calculation node (script) inlined (and executed) in the schema.
Definition: InlineNode.hxx:44
static const char LOCAL_STR[]
Definition: InlineNode.hxx:72
virtual Container * getContainer()
Definition: InlineNode.cxx:100
virtual void setScript(const std::string &script)
Set the script (as a string) to execute.
Definition: InlineNode.cxx:50
virtual void setContainer(Container *container)
Definition: InlineNode.cxx:105
void performDuplicationOfPlacement(const Node &other)
performs a duplication of placement using clone method of containers and components....
Definition: InlineNode.cxx:115
static const char REMOTE_STR[]
Definition: InlineNode.hxx:73
virtual std::string getExecutionMode()
Definition: InlineNode.cxx:95
int getMaxLevelOfParallelism() const
Definition: InlineNode.cxx:142
virtual void setExecutionMode(const std::string &mode)
Definition: InlineNode.cxx:85
virtual void accept(Visitor *visitor)
Definition: InlineNode.cxx:41
void performShallowDuplicationOfPlacement(const Node &other)
performs a also duplication of placement but here containers and components are not copied at all wha...
Definition: InlineNode.cxx:123
Base class for all nodes.
Definition: Node.hxx:70
virtual void visitInlineFuncNode(InlineFuncNode *node)=0
virtual void visitInlineNode(InlineNode *node)=0