|
| Branch (const std::string &branch_name, DataType *handle=nullptr) |
| Attach ourselves to the input type after construction. More...
|
|
void | load () final override |
| Loading this dataset from the file involves simply loading all of the members of the data type. More...
|
|
void | attach (Reader &f) final override |
| pure virtual method for loading data from the input file More...
|
|
void | save () final override |
| pure virtual method for saving data More...
|
|
void | attach (Writer &f) final override |
| pure virtual method for saving structure More...
|
|
template<typename MemberType > |
void | attach (const std::string &name, MemberType &m, SaveLoad sl=SaveLoad::Both) |
| Attach a member object from the our data handle. More...
|
|
template<typename MemberType > |
void | rename (const std::string &old_name, const std::string &new_name, MemberType &m) |
| Rename a member variable. More...
|
|
| AbstractBranch (const std::string &branch_name, DataType *handle=nullptr) |
| Define the dataset branch_name and provide an optional handle. More...
|
|
virtual | ~AbstractBranch () |
| Delete our object if we own it, otherwise do nothing. More...
|
|
virtual void | clear () |
| Define the clear function here to handle the most common cases. More...
|
|
virtual const DataType & | get () const |
| Get the current in-memory data. More...
|
|
int | version () const |
| Get the version number for the type we are loading from. More...
|
|
virtual void | update (const DataType &val) |
| Update the in-memory data object with the passed value. More...
|
|
DataType & | operator* () |
| Access the in-memory data object.
|
|
const DataType & | operator* () const |
| Access the in-memory data opbject in a const manner.
|
|
DataType * | operator-> () |
| Pointer access to the in-memory data type.
|
|
const DataType * | operator-> () const |
| Pointer access to the in-memory data type in a const manner.
|
|
| BaseBranch (const std::string &full_name) |
| define the full name of the branch
|
|
virtual | ~BaseBranch ()=default |
| virtual destructor so inherited classes can be properly destructed.
|
|
| BaseBranch (const BaseBranch &)=delete |
| no copying
|
|
BaseBranch & | operator= (const BaseBranch &)=delete |
| no copying
|
|
template<typename DataType, typename Enable = void>
class hdtree::Branch< DataType, Enable >
General data set.
This is the top-level data set that will be used most often. It is meant to be used by a class which registers its member variables to this set via the io::DataSet<DataType>::attach method.
More complete documentation is kept in the documentation of the hdtree namespace; nevertheless, a short example is kept here.
public:
private:
template<typename Branch>
b.attach("my_double",my_double_);
if (b.version() < 2) b.rename("old","new",new_);
else b.attach("new",new_);
}
my_double_ = -1;
new_ = 0;
}
private:
double my_double_;
int new_;
int i_wont_be_on_disk_;
};
#define hdtree_class_version(VERS)
define the version number for a class
Definition: ClassVersion.h:85
Example user class.
Definition: user_class.cxx:18
virtual void clear()
Define the clear function here to handle the most common cases.
Definition: AbstractBranch.h:171
Branch(const std::string &branch_name, DataType *handle=nullptr)
Attach ourselves to the input type after construction.
Definition: GeneralBranch.h:73
void attach(Reader &f) final override
pure virtual method for loading data from the input file
Definition: GeneralBranch.h:110
empty struct for connecting a instance of Data and the type it wraps
Definition: Access.h:21
template<typename DataType , typename Enable = void>
template<typename MemberType >
void hdtree::Branch< DataType, Enable >::attach |
( |
const std::string & |
name, |
|
|
MemberType & |
m, |
|
|
SaveLoad |
sl = SaveLoad::Both |
|
) |
| |
|
inline |
Attach a member object from the our data handle.
We create a new child Branch so that we can recursively handle complex member variable types.
- Template Parameters
-
MemberType | type of member variable we are attaching |
- Parameters
-
[in] | name | name of member variable |
[in] | m | reference of member variable |
[in] | save | write this member into output files (if the class is being written) |
[in] | load | load this member from an input file (if being read) |
template<typename DataType , typename Enable = void>
|
inlinefinaloverridevirtual |
Loading this dataset from the file involves simply loading all of the members of the data type.
We catch a HighFive exception early here so that we can detail to the user which class is causing the read issue. This is especially helpful in the case of containers of user types since the issue is (probably) not coming from serialization of the container.
- Exceptions
-
- Parameters
-
Implements hdtree::AbstractBranch< DataType >.
template<typename DataType , typename Enable = void>
template<typename MemberType >
void hdtree::Branch< DataType, Enable >::rename |
( |
const std::string & |
old_name, |
|
|
const std::string & |
new_name, |
|
|
MemberType & |
m |
|
) |
| |
|
inline |
Rename a member variable.
This is a simple helper-function wrapping attach which does the two calls for the user sharing the same member variable, creating one member for loading from the old_name and one member for writing to the new_name.
- Template Parameters
-
MemberType | type of member variable we are attaching |
- Parameters
-
[in] | old_name | name of member variable in version being read from file |
[in] | new_name | name of member variable in version being written to output file |
[in] | m | reference of member variable |
template<typename DataType , typename Enable = void>
list of members in this dataset
the extra boolean flags are to tell us if that member should be loaded from the input file and/or saved to the output file
This is the core of schema evolution.