From 6eb6c1dbb9b590713321c08bd05aead8716e212f Mon Sep 17 00:00:00 2001 From: fps Date: Wed, 18 Sep 2013 09:41:35 +0000 Subject: [PATCH] add setComponentsNames --- src/XAO/XAO_Field.cxx | 10 ++++++++++ src/XAO/XAO_Field.hxx | 6 ++++++ src/XAO/tests/FieldTest.hxx | 2 ++ 3 files changed, 18 insertions(+) diff --git a/src/XAO/XAO_Field.cxx b/src/XAO/XAO_Field.cxx index a38105b0e..51d73616c 100644 --- a/src/XAO/XAO_Field.cxx +++ b/src/XAO/XAO_Field.cxx @@ -78,6 +78,16 @@ throw (XAO_Exception) m_components[index] = name; } +void Field::setComponentsNames(const std::vector& names) +throw (XAO_Exception) +{ + for (int i = 0; i < names.size(); ++i) + { + if (i < m_nbComponents) + m_components[i] = names[i]; + } +} + bool Field::removeStep(Step* step) { std::vector::iterator it = m_steps.begin(); diff --git a/src/XAO/XAO_Field.hxx b/src/XAO/XAO_Field.hxx index 88e5f66ee..e1931d587 100644 --- a/src/XAO/XAO_Field.hxx +++ b/src/XAO/XAO_Field.hxx @@ -149,6 +149,12 @@ namespace XAO */ void setComponentName(const int& componentIndex, const std::string& name) throw (XAO_Exception); + /** + * Sets the name of the components. + * @param names the names to set. + */ + void setComponentsNames(const std::vector& names) throw (XAO_Exception); + /** * Adds a new step of the same type than the field. * @param number the numer of the step. diff --git a/src/XAO/tests/FieldTest.hxx b/src/XAO/tests/FieldTest.hxx index 9a4a8d82d..35e766576 100644 --- a/src/XAO/tests/FieldTest.hxx +++ b/src/XAO/tests/FieldTest.hxx @@ -24,6 +24,7 @@ namespace XAO CPPUNIT_TEST(testIntegerStepValues); CPPUNIT_TEST(testDoubleStepValues); CPPUNIT_TEST(testStringStepValues); + CPPUNIT_TEST(testSetComponents); CPPUNIT_TEST_SUITE_END(); public: @@ -47,6 +48,7 @@ namespace XAO void testIntegerStepValues(); void testDoubleStepValues(); void testStringStepValues(); + void testSetComponents(); }; } -- 2.39.2