DataSetImpl.hpp 1.64 KB
Newer Older
Matthieu Dorier's avatar
Matthieu Dorier committed
1 2 3 4 5
/*
 * (C) 2018 The University of Chicago
 * 
 * See COPYRIGHT in top-level directory.
 */
6 7 8 9
#ifndef __HEPNOS_PRIVATE_DATASET_IMPL_H
#define __HEPNOS_PRIVATE_DATASET_IMPL_H

#include "hepnos/DataSet.hpp"
10
#include "hepnos/RunSet.hpp"
Matthieu Dorier's avatar
Matthieu Dorier committed
11
#include "hepnos/UUID.hpp"
12 13 14

namespace hepnos {

15 16
class DataStoreImpl;

17
class DataSetImpl {
18 19 20

    public:

21 22 23 24
        std::shared_ptr<DataStoreImpl>  m_datastore;
        uint8_t                         m_level;
        std::shared_ptr<std::string>    m_container;
        std::string                     m_name;
Matthieu Dorier's avatar
Matthieu Dorier committed
25
        UUID                            m_uuid;
26

27 28
        static DataSet::iterator m_end;

29
        DataSetImpl(const std::shared_ptr<DataStoreImpl>& ds,
30 31
             uint8_t level, 
             const std::shared_ptr<std::string>& container,
Matthieu Dorier's avatar
Matthieu Dorier committed
32 33
             const std::string& name,
             const UUID& uuid = UUID())
34 35 36
        : m_datastore(ds)
        , m_level(level)
        , m_container(container)
Matthieu Dorier's avatar
Matthieu Dorier committed
37 38
        , m_name(name)
        , m_uuid(uuid) {}
39

40
        DataSetImpl(const std::shared_ptr<DataStoreImpl>& ds,
41
             uint8_t level,
Matthieu Dorier's avatar
Matthieu Dorier committed
42 43
             const std::string& fullname,
             const UUID& uuid = UUID())
44
        : m_datastore(ds)
Matthieu Dorier's avatar
Matthieu Dorier committed
45 46
        , m_level(level)
        , m_uuid(uuid) {
47
            size_t p = fullname.find_last_of('/');
48 49
            m_name = fullname.substr(p+1);
            m_container = std::make_shared<std::string>(fullname.substr(0, p));
50 51 52
        }

        std::string fullname() const {
53 54 55 56
            auto result = *m_container;
            if(m_name.size() > 0)
                result += "/" + m_name; // we do this because the root dataset has m_name == ""
            return result;
57
        }
58 59 60 61 62
};

}

#endif