friend class Loop;
friend class OutPort;
friend class ElementaryNode;
- protected:
+ public:
static const char SEP_CHAR_BTW_LEVEL[];
protected:
ComposedNode(const std::string& name);
_implementation(Runtime::RUNTIME_ENGINE_INTERACTION_IMPL_NAME),_modified(1)
{
// Should be protected by lock ??
+ Node::checkValidityOfNodeName(_name);
_numId = _total++;
idMap[_numId]=this;
*/
void Node::setName(const std::string& name)
{
+ Node::checkValidityOfNodeName(name);
if(_father)
{
if(_father->isNameAlreadyUsed(name))
}
}
+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
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);
};
}
void Proc::setName(const std::string& name)
{
+ Node::checkValidityOfNodeName(name);
_name = name;
}
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);
+}
CPPUNIT_TEST( testForCheckConsistency3 );
CPPUNIT_TEST( testForCheckConsistency4 );
CPPUNIT_TEST( testRemoveRuntime );
+ CPPUNIT_TEST( testWrongNodeNameDetection );
CPPUNIT_TEST_SUITE_END();
public:
void setUp();
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);