1 // Copyright (C) 2006-2019 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "InlineNode.hxx"
21 #include "Visitor.hxx"
22 #include "Container.hxx"
23 #include "HomogeneousPoolContainer.hxx"
27 #include "YacsTrace.hxx"
29 using namespace YACS::ENGINE;
32 const char InlineNode::LOCAL_STR[]="local";
34 const char InlineNode::REMOTE_STR[]="remote";
36 InlineNode::~InlineNode()
39 _container->decrRef();
42 void InlineNode::accept(Visitor *visitor)
44 visitor->visitInlineNode(this);
47 //! Set the script (as a string) to execute
49 * \param script: script to execute
51 void InlineNode::setScript(const std::string& script)
58 InlineFuncNode::~InlineFuncNode()
62 void InlineFuncNode::accept(Visitor *visitor)
64 visitor->visitInlineFuncNode(this);
68 * \param fname: name of the function contained in the script to execute
70 void InlineFuncNode::setFname(const std::string& fname)
76 void InlineFuncNode::checkBasicConsistency() const throw(YACS::Exception)
78 InlineNode::checkBasicConsistency();
81 string mess = "Function name is not defined";
82 throw Exception(mess);
86 void InlineNode::setExecutionMode(const std::string& mode)
88 if(mode == _mode)return;
89 if(mode == LOCAL_STR || mode == REMOTE_STR)
96 std::string InlineNode::getExecutionMode()
101 Container* InlineNode::getContainer()
106 void InlineNode::setContainer(Container* cont)
108 if (cont == _container) return;
110 _container->decrRef();
113 _container->incrRef();
116 void InlineNode::performDuplicationOfPlacement(const Node& other)
118 const InlineNode &otherC=*(dynamic_cast<const InlineNode *>(&other));
119 //if other has no container don't clone: this will not have one
120 if(otherC._container)
121 _container=otherC._container->clone();
124 void InlineNode::performShallowDuplicationOfPlacement(const Node& other)
126 const InlineNode &otherC=*(dynamic_cast<const InlineNode *>(&other));
127 //if other has no container don't clone: this will not have one
128 if(otherC._container)
130 _container=otherC._container;
131 _container->incrRef();
135 bool InlineNode::isDeployable() const
137 if(_mode==REMOTE_STR)
143 int InlineNode::getMaxLevelOfParallelism() const
149 std::map<std::string,std::string> props(_container->getProperties());
150 std::map<std::string,std::string>::iterator it(props.find(std::string("nb_proc_per_node")));
153 if((*it).second.empty())
155 std::istringstream iss((*it).second);
156 int ret(1); iss >> ret;
160 void InlineNode::partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap)
166 HomogeneousPoolContainer *contC(dynamic_cast<HomogeneousPoolContainer *>(_container));
169 YACS::BASES::AutoConstRefCnt<PartDefinition> zePd;
171 YACS::BASES::AutoRefCnt<HomogeneousPoolContainer> zeCont(contC->decorate(zePd));
172 setContainer(zeCont);