Salome HOME
Merge Python 3 porting.
[modules/yacs.git] / src / engine / InlineNode.cxx
index b2f4b757a1cb05b6b1798408d9c78e3b233b0c01..ce696f61805937e7fe9fdd35fb747a4372a4ac94 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006-2014  CEA/DEN, EDF R&D
+// Copyright (C) 2006-2016  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -20,6 +20,7 @@
 #include "InlineNode.hxx"
 #include "Visitor.hxx"
 #include "Container.hxx"
+#include "HomogeneousPoolContainer.hxx"
 #include <iostream>
 
 #define _DEVDEBUG_
@@ -28,6 +29,9 @@
 using namespace YACS::ENGINE;
 using namespace std;
 
+const char InlineNode::LOCAL_STR[]="local";
+
+const char InlineNode::REMOTE_STR[]="remote";
 
 InlineNode::~InlineNode()
 {
@@ -82,7 +86,7 @@ void InlineFuncNode::checkBasicConsistency() const throw(YACS::Exception)
 void InlineNode::setExecutionMode(const std::string& mode)
 {
   if(mode == _mode)return;
-  if(mode == "local"||mode == "remote")
+  if(mode == LOCAL_STR || mode == REMOTE_STR)
     {
       _mode=mode;
       modified();
@@ -117,11 +121,53 @@ void InlineNode::performDuplicationOfPlacement(const Node& other)
     _container=otherC._container->clone();
 }
 
+void InlineNode::performShallowDuplicationOfPlacement(const Node& other)
+{
+  const InlineNode &otherC=*(dynamic_cast<const InlineNode *>(&other));
+  //if other has no container don't clone: this will not have one
+  if(otherC._container)
+    {
+      _container=otherC._container;
+      _container->incrRef();
+    }
+}
+
 bool InlineNode::isDeployable() const
 {
-  if(_mode=="remote")
+  if(_mode==REMOTE_STR)
     return true;
   else
     return false;
 }
 
+int InlineNode::getMaxLevelOfParallelism() const
+{
+  if(!isDeployable())
+    return 1;
+  if(!_container)
+    return 1;
+  std::map<std::string,std::string> props(_container->getProperties());
+  std::map<std::string,std::string>::iterator it(props.find(std::string("nb_proc_per_node")));
+  if(it==props.end())
+    return 1;
+  if((*it).second.empty())
+    return 1;
+  std::istringstream iss((*it).second);
+  int ret(1); iss >> ret;
+  return ret;
+}
+
+void InlineNode::partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap)
+{
+  if(!isDeployable())
+    return ;
+  if(!_container)
+    return ;
+  HomogeneousPoolContainer *contC(dynamic_cast<HomogeneousPoolContainer *>(_container));
+  if(!contC)
+    return ;
+  YACS::BASES::AutoConstRefCnt<PartDefinition> zePd;
+  zePd.takeRef(pd);
+  YACS::BASES::AutoRefCnt<HomogeneousPoolContainer> zeCont(contC->decorate(zePd));
+  setContainer(zeCont);
+}