Salome HOME
Copyright update 2022
[modules/yacs.git] / src / engine / NbBranches.cxx
index b9528aeb7c14f66aa2191c70c6cc6812ce198cf7..bffeaa1a886fc74ad91b81af4f2c96561bc89cc4 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006-2020  CEA/DEN, EDF R&D
+// Copyright (C) 2006-2022  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
 
 using namespace YACS::ENGINE;
 
-const char NbBranches::NAME_OF_NUMBER_OF_BRANCHES[]="nbBranches";
+const char NbBranchesAbstract::NAME_OF_NUMBER_OF_BRANCHES[]="nbBranches";
+
+bool NbBranchesAbstract::IsBranchPortName(const std::string& name)
+{
+  return name == NAME_OF_NUMBER_OF_BRANCHES;
+}
+
+std::unique_ptr<NbBranchesAbstract> NbBranches::copy(Node *node) const
+{
+  return std::unique_ptr<NbBranchesAbstract>(new NbBranches(*this,node));
+}
+
+int NbBranches::getNumberOfBranches(int) const
+{
+  return this->getIntValue();
+}
+
+bool NbBranches::isMyName(const std::string& name) const
+{
+  return NbBranchesAbstract::IsBranchPortName(name);
+}
 
 void NbBranches::exInit(bool start)
 {
-    _nbOfBranches.exInit(start);
+  _nbOfBranches.exInit(start);
 }
 
 InputPort *NbBranches::getPort() const
 {
-    return const_cast<AnyInputPort *>(&_nbOfBranches);
+  return const_cast<AnyInputPort *>(&_nbOfBranches);
 }
 
 bool NbBranches::isMultiplicitySpecified(unsigned& value) const
@@ -40,7 +60,7 @@ bool NbBranches::isMultiplicitySpecified(unsigned& value) const
     {
       value=_nbOfBranches.getIntValue();
       return true;
-    }   
+    }
   return false;
 }
 
@@ -50,7 +70,36 @@ void NbBranches::forceMultiplicity(unsigned value)
   _nbOfBranches.edInit((int)value);
 }
 
-bool NbBranches::IsBranchPortName(const std::string& name)
+std::unique_ptr<NbBranchesAbstract> NoNbBranches::copy(Node *) const
 {
-  return name == NAME_OF_NUMBER_OF_BRANCHES;
-}
\ No newline at end of file
+  return std::unique_ptr<NbBranchesAbstract>(new NoNbBranches);
+}
+
+int NoNbBranches::getNumberOfBranches(int nbOfElems) const
+{
+  return nbOfElems;
+}
+
+void NoNbBranches::exInit(bool start)
+{
+}
+
+InputPort *NoNbBranches::getPort() const
+{
+  return nullptr;
+}
+
+bool NoNbBranches::isMultiplicitySpecified(unsigned& value) const
+{
+  return false;
+}
+
+void NoNbBranches::forceMultiplicity(unsigned value)
+{
+  throw Exception("NoNbBranches::forceMultiplicity : impossible to be forced !");
+}
+
+int NoNbBranches::getIntValue() const
+{
+  throw Exception("NoNbBranches::getIntValue : no value stored !");
+}