HDTree  0.5.2
HDTree C++ API
hdtree::Branch< std::map< KeyType, ValType > > Class Template Reference

Our wrapper around std::map. More...

#include <MapBranch.h>

Inheritance diagram for hdtree::Branch< std::map< KeyType, ValType > >:
[legend]
Collaboration diagram for hdtree::Branch< std::map< KeyType, ValType > >:
[legend]

Public Member Functions

 Branch (const std::string &branch_name, std::map< KeyType, ValType > *handle=nullptr)
 We create three child data sets, one for the successive sizes of the maps and two to hold all the keys and values serially. More...
 
void load () final override
 Load a map from the input file. More...
 
void attach (Reader &f) final override
 pure virtual method for loading data from the input file More...
 
void save () final override
 Save a vector to the output file. More...
 
void attach (Writer &f) final override
 pure virtual method for saving structure More...
 
- Public Member Functions inherited from hdtree::AbstractBranch< std::map< KeyType, ValType > >
 AbstractBranch (const std::string &branch_name, std::map< KeyType, ValType > *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 std::map< KeyType, ValType > & 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 std::map< KeyType, ValType > &val)
 Update the in-memory data object with the passed value. More...
 
std::map< KeyType, ValType > & operator* ()
 Access the in-memory data object.
 
const std::map< KeyType, ValType > & operator* () const
 Access the in-memory data opbject in a const manner.
 
std::map< KeyType, ValType > * operator-> ()
 Pointer access to the in-memory data type.
 
const std::map< KeyType, ValType > * operator-> () const
 Pointer access to the in-memory data type in a const manner.
 
- Public Member Functions inherited from hdtree::BaseBranch
 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
 
BaseBranchoperator= (const BaseBranch &)=delete
 no copying
 

Private Member Functions

 hdtree_class_version (1)
 

Private Attributes

Branch< std::size_t > size_
 the data set of sizes of the vectors
 
Branch< KeyType > keys_
 the data set holding the content of all the keys
 
Branch< ValType > vals_
 the data set holding the content of all the vals
 

Additional Inherited Members

- Protected Attributes inherited from hdtree::AbstractBranch< std::map< KeyType, ValType > >
std::optional< std::pair< std::string, int > > load_type_
 type this data is loading from
 
std::pair< std::string, int > save_type_
 type this data that is being used to write
 
std::map< KeyType, ValType > * handle_
 handle on current object in memory
 
bool owner_
 we own the object in memory
 
- Protected Attributes inherited from hdtree::BaseBranch
std::string name_
 name of branch
 

Detailed Description

template<typename KeyType, typename ValType>
class hdtree::Branch< std::map< KeyType, ValType > >

Our wrapper around std::map.

Very similar implementation as vectors, just having two columns rather than only one.

Note
We assume the load/save is done sequentially. Similar rational as io::Branch<std::vector<ContentType>>
Template Parameters
KeyTypetype that the keys in the map are
ValTypetype that the vals in the map are

Constructor & Destructor Documentation

◆ Branch()

template<typename KeyType , typename ValType >
hdtree::Branch< std::map< KeyType, ValType > >::Branch ( const std::string &  branch_name,
std::map< KeyType, ValType > *  handle = nullptr 
)
inlineexplicit

We create three child data sets, one for the successive sizes of the maps and two to hold all the keys and values serially.

Parameters
[in]branch_namefull in-file branch_name to set holding this data
[in]handlepointer to object already constructed (optional)

Member Function Documentation

◆ attach() [1/2]

template<typename KeyType , typename ValType >
void hdtree::Branch< std::map< KeyType, ValType > >::attach ( Reader f)
inlinefinaloverridevirtual

pure virtual method for loading data from the input file

Parameters
[in]fReader to load from

Implements hdtree::AbstractBranch< std::map< KeyType, ValType > >.

◆ attach() [2/2]

template<typename KeyType , typename ValType >
void hdtree::Branch< std::map< KeyType, ValType > >::attach ( Writer f)
inlinefinaloverridevirtual

pure virtual method for saving structure

Parameters
[in]fWriter to write to

Implements hdtree::AbstractBranch< std::map< KeyType, ValType > >.

◆ load()

template<typename KeyType , typename ValType >
void hdtree::Branch< std::map< KeyType, ValType > >::load ( )
inlinefinaloverridevirtual

Load a map from the input file.

Note
We assume that the loads are done sequentially.

We read the next size and then read that many items from the keys/vals data sets into the map handle.

Parameters
[in]fh5::Reader to load from

Implements hdtree::AbstractBranch< std::map< KeyType, ValType > >.

◆ save()

template<typename KeyType , typename ValType >
void hdtree::Branch< std::map< KeyType, ValType > >::save ( )
inlinefinaloverridevirtual

Save a vector to the output file.

Note
We assume that the saves are done sequentially.

We write the size and the keys/vals onto the end of their data sets.

Parameters
[in]fio::Writer to save to

Implements hdtree::AbstractBranch< std::map< KeyType, ValType > >.


The documentation for this class was generated from the following file: