MarlinMT  0.1.0
EntryData.h
Go to the documentation of this file.
1 #pragma once
2 
3 // -- std includes
4 #include <filesystem>
5 #include <memory>
6 #include <string>
7 #include <typeindex>
8 
9 // -- MarlinBook includes
10 #include "marlinmt/book/Flags.h"
11 #include "marlinmt/book/Types.h"
12 
13 namespace marlinmt {
14  namespace book {
15  // -- MarlinBook forward declaration
16  class MemLayout ;
17 
21  struct EntryKey {
22 
24  EntryKey() = default ;
25 
27  explicit EntryKey( const std::type_index &t ) : type{t} {}
28 
30  std::filesystem::path path{""} ;
32  std::size_t mInstances{0} ;
34  std::type_index type{typeid( void )} ;
38  std::size_t idx{std::numeric_limits<std::size_t>::max()} ;
39  } ;
40 
44  template < class T >
45  class EntryDataBase {} ;
46 
47  template <>
48  class EntryDataBase< void > {
49  public:
50  EntryDataBase() = default ;
51  EntryDataBase( const EntryDataBase & ) = delete ;
52  EntryDataBase &operator=( const EntryDataBase & ) = delete ;
53  EntryDataBase( EntryDataBase<void> && ) = delete ;
54  EntryDataBase &operator=( EntryDataBase && ) = delete ;
55  ~EntryDataBase() = default ;
56 
57  // template<typename ... Args_t>
58  // void book(BookStore & store, Args_t... args){
59  // }
60  } ;
61 
65  template < class T, unsigned long long = 0>
66  class EntryData : public EntryDataBase< void > {} ;
67 
71  struct Context {
72 
74  Context() = default ;
75 
77  explicit Context( std::shared_ptr< MemLayout > memLayout,
78  std::size_t numInstances)
79  : mem{std::move( memLayout )},
80  nInstances{numInstances} {}
81 
83  std::shared_ptr< MemLayout > mem{nullptr} ;
84  std::size_t nInstances{0};
85  } ;
86 
88  class EntryBase {} ;
89 
90  } // end namespace book
91 } // end namespace marlinmt
92 
93 namespace std {
94  template<>
95  struct less<marlinmt::book::EntryKey> {
96  bool operator()(
97  const marlinmt::book::EntryKey& lh,
98  const marlinmt::book::EntryKey& rh) const
99  {
100  return lh.idx < rh.idx;
101  }
102  };
103 } // end namespace std
104 
Data selection to identify and manage an Entry.
Definition: EntryData.h:21
bool operator()(const marlinmt::book::EntryKey &lh, const marlinmt::book::EntryKey &rh) const
Definition: EntryData.h:96
std::size_t mInstances
number of memory instances
Definition: EntryData.h:32
Flag_t flags
Status flags from Entry.
Definition: EntryData.h:36
Container for data to construct and setup booked object.
Definition: EntryData.h:66
constexpr ValidatorFunctionT< T > less(T limit)
Validator function checking for the value to be less than a limit.
Definition: Validator.h:74
EntryKey(const std::type_index &t)
Construct typed EntryKey.
Definition: EntryData.h:27
Definition: EntryData.h:93
std::filesystem::path path
virtual Entry path
Definition: EntryData.h:30
Context(std::shared_ptr< MemLayout > memLayout, std::size_t numInstances)
constructor
Definition: EntryData.h:77
Flag type for flags in marlinmt::book.
Definition: Flags.h:15
Base type for Entries. To avoid void pointer.
Definition: EntryData.h:88
Base Class for Entry Data, for similar behavior.
Definition: EntryData.h:45
std::size_t idx
unique number for Entry
Definition: EntryData.h:38
Data selection for the Entry to work properly.
Definition: EntryData.h:71
std::type_index type
Type of object stored in Entry.
Definition: EntryData.h:34
EntryKey()=default
default constructor.