]> SALOME platform Git repositories - modules/yacs.git/commitdiff
Salome HOME
YACS does not support Node names with . So now an exception is thrown when attempting...
authorAnthony Geay <anthony.geay@edf.fr>
Tue, 7 May 2019 12:15:50 +0000 (14:15 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Tue, 7 May 2019 12:15:50 +0000 (14:15 +0200)
src/engine/ComposedNode.hxx
src/engine/Node.cxx
src/engine/Node.hxx
src/engine/Proc.cxx
src/engine/Test/engineIntegrationTest.cxx
src/engine/Test/engineIntegrationTest.hxx

index 177e9404d856547f788de490060b78d6f1cfc920..0d6e78314cc14e08443b69d5cd72e9d662354d9f 100644 (file)
@@ -45,7 +45,7 @@ namespace YACS
       friend class Loop;
       friend class OutPort;
       friend class ElementaryNode;
-    protected:
+    public:
       static const char SEP_CHAR_BTW_LEVEL[];
     protected:
       ComposedNode(const std::string& name);
index 5c9d8fdb25054409a9d2c2c0b9a237e581b7c72e..f7d8196adc85498b2e14f0fbef071b91ebf820af 100644 (file)
@@ -69,6 +69,7 @@ Node::Node(const std::string& name):_name(name),_inGate(this),_outGate(this),_fa
                                     _implementation(Runtime::RUNTIME_ENGINE_INTERACTION_IMPL_NAME),_modified(1)
 {
   // Should be protected by lock ??
+  Node::checkValidityOfNodeName(_name);
   _numId = _total++;
   idMap[_numId]=this;
 
@@ -158,6 +159,7 @@ Node *Node::cloneWithoutCompAndContDeepCpy(ComposedNode *father, bool editionOnl
  */
 void Node::setName(const std::string& name)
 {
+  Node::checkValidityOfNodeName(name);
   if(_father)
     {
       if(_father->isNameAlreadyUsed(name))
@@ -448,6 +450,15 @@ void Node::checkValidityOfPortName(const std::string& name) throw(YACS::Exceptio
     }
 }
 
+void Node::checkValidityOfNodeName(const std::string& name)
+{
+  if(name.find(ComposedNode::SEP_CHAR_BTW_LEVEL,0)!=string::npos)
+    {
+      string what("Node name "); what+=name; what+="not valid because it contains character "; what+=ComposedNode::SEP_CHAR_BTW_LEVEL;
+      throw Exception(what);
+    }
+}
+
 /**
  * @note : Check that 'node1' and 'node2' have exactly the same father
  * @exception : If 'node1' and 'node2' have NOT exactly the same father
index d432413311cac391727f8a3baf58e1e930fce936..fbd22767001f97d43210899c01f629f32508118f 100644 (file)
@@ -202,6 +202,8 @@ namespace YACS
       virtual void edDisconnectAllLinksWithMe();
       static void checkValidityOfPortName(const std::string& name) throw(Exception);
       static ComposedNode *checkHavingCommonFather(Node *node1, Node *node2) throw(Exception);
+    public:
+      static void checkValidityOfNodeName(const std::string& name);
     };
 
   }
index 8b9b92d629f1ce7e3ffeda0305086de20a88040e..f2499cd0f8f5c275460d08332307c88924bebfaf 100644 (file)
@@ -203,6 +203,7 @@ void Proc::accept(Visitor *visitor)
 
 void Proc::setName(const std::string& name)
 {
+  Node::checkValidityOfNodeName(name);
   _name = name;
 }
 
index f118deb36fb1c43534b6c69a7567a3c40b664f31..7c990762f5c6497ed9210f5e15b2603345160fba 100644 (file)
@@ -3272,3 +3272,11 @@ void EngineIntegrationTest::testRemoveRuntime()
   Runtime* r=YACS::ENGINE::getRuntime();
   delete r;
 }
+
+void EngineIntegrationTest::testWrongNodeNameDetection()
+{
+  ToyNode *n1=new ToyNode("T1");
+  CPPUNIT_ASSERT_THROW(n1->setName("jjj.jj"),YACS::Exception);
+  delete n1;
+  CPPUNIT_ASSERT_THROW(ToyNode("T1.DD"),YACS::Exception);
+}
index a6b62ec47012db5614774714aff4cd656b39f5a2..1303a1903c2a93ef43df0fff332c75e74e8bedfe 100644 (file)
@@ -70,6 +70,7 @@ namespace YACS
       CPPUNIT_TEST( testForCheckConsistency3 );
       CPPUNIT_TEST( testForCheckConsistency4 );
       CPPUNIT_TEST( testRemoveRuntime );
+      CPPUNIT_TEST( testWrongNodeNameDetection );
       CPPUNIT_TEST_SUITE_END();
     public:
       void setUp();
@@ -112,6 +113,7 @@ namespace YACS
       void testForCheckConsistency3();
       void testForCheckConsistency4();
       void testRemoveRuntime();
+      void testWrongNodeNameDetection();
     protected:
       template<class T>
       static void checkListsEqual(const std::list<T>& setToTest1, const std::list<T>& setToTest2);