Commit 06c5e3ef authored by Matthieu Dorier's avatar Matthieu Dorier

changed the semantics of fullname so that it includes a root /

parent 39c230b4
......@@ -186,10 +186,7 @@ DataSet::iterator DataSet::find(const std::string& datasetPath) {
containerName = parent;
} else {
size_t c = datasetPath.find_last_of('/');
if(parent.size() > 0)
containerName = parent + "/" + datasetPath.substr(0,c);
else
containerName = datasetPath.substr(0,c);
containerName = parent + "/" + datasetPath.substr(0,c);
datasetName = datasetPath.substr(c+1);
}
......
......@@ -39,20 +39,15 @@ class DataSetImpl {
: m_datastore(ds)
, m_level(level) {
size_t p = fullname.find_last_of('/');
if(p == std::string::npos) {
m_name = fullname;
m_container = std::make_shared<std::string>("");
} else {
m_name = fullname.substr(p+1);
m_container = std::make_shared<std::string>(fullname.substr(0, p));
}
m_name = fullname.substr(p+1);
m_container = std::make_shared<std::string>(fullname.substr(0, p));
}
std::string fullname() const {
if(m_container->size() > 0)
return *m_container + "/" + m_name;
else
return m_name;
auto result = *m_container;
if(m_name.size() > 0)
result += "/" + m_name; // we do this because the root dataset has m_name == ""
return result;
}
};
......
......@@ -32,8 +32,8 @@ void DataSetTest::testFillDataStore() {
// assert the characteristics of the created dataset
CPPUNIT_ASSERT(ds1.valid());
CPPUNIT_ASSERT_EQUAL_STR("ds1", ds1.name());
CPPUNIT_ASSERT_EQUAL_STR("matthieu", ds1.container());
CPPUNIT_ASSERT_EQUAL_STR("matthieu/ds1", ds1.fullname());
CPPUNIT_ASSERT_EQUAL_STR("/matthieu", ds1.container());
CPPUNIT_ASSERT_EQUAL_STR("/matthieu/ds1", ds1.fullname());
// assert access from DataStore using full path
DataSet matthieu_ds1 = root["matthieu/ds1"];
std::cerr << "BBBB" << std::endl;
......@@ -92,8 +92,8 @@ void DataSetTest::testBraketOperator() {
DataSet ds2 = mds["ds2"];
CPPUNIT_ASSERT(ds2.valid());
CPPUNIT_ASSERT_EQUAL_STR("ds2", ds2.name());
CPPUNIT_ASSERT_EQUAL_STR("matthieu", ds2.container());
CPPUNIT_ASSERT_EQUAL_STR("matthieu/ds2", ds2.fullname());
CPPUNIT_ASSERT_EQUAL_STR("/matthieu", ds2.container());
CPPUNIT_ASSERT_EQUAL_STR("/matthieu/ds2", ds2.fullname());
}
void DataSetTest::testFind() {
......@@ -193,7 +193,7 @@ void DataSetTest::testCreateRuns() {
Run r = mds.createRun(45);
CPPUNIT_ASSERT(r.valid());
CPPUNIT_ASSERT(45 == r.number());
CPPUNIT_ASSERT_EQUAL_STR("matthieu", r.container());
CPPUNIT_ASSERT_EQUAL_STR("/matthieu", r.container());
}
}
......@@ -25,7 +25,7 @@ void DataStoreTest::testFillDataStore() {
CPPUNIT_ASSERT(ds1.valid());
CPPUNIT_ASSERT_EQUAL_STR("ds1", ds1.name());
CPPUNIT_ASSERT_EQUAL_STR("", ds1.container());
CPPUNIT_ASSERT_EQUAL_STR("ds1", ds1.fullname());
CPPUNIT_ASSERT_EQUAL_STR("/ds1", ds1.fullname());
// assert invalid dataset when it does not exist
CPPUNIT_ASSERT_THROW(datastore->root()["invalid"], hepnos::Exception);
// assert comparison with a default-constructed dataset
......
......@@ -26,7 +26,7 @@ void RunSetTest::testFillDataStore() {
// assert the characteristics of the created dataset
CPPUNIT_ASSERT(r1.valid());
CPPUNIT_ASSERT(42 == r1.number());
CPPUNIT_ASSERT_EQUAL_STR("matthieu", r1.container());
CPPUNIT_ASSERT_EQUAL_STR("/matthieu", r1.container());
// assert comparison with a default-constructed run
CPPUNIT_ASSERT(r0 != r1);
CPPUNIT_ASSERT(!(r0 == r1));
......@@ -62,7 +62,7 @@ void RunSetTest::testBraketOperator() {
Run r2 = mds[45];
CPPUNIT_ASSERT(r2.valid());
CPPUNIT_ASSERT(45 == r2.number());
CPPUNIT_ASSERT_EQUAL_STR("matthieu", r2.container());
CPPUNIT_ASSERT_EQUAL_STR("/matthieu", r2.container());
// check that we access the same Run using the runs() function
// to go through the RunSet
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment