HDTree  0.5.2
HDTree C++ API
hdtree::Branch< AtomicType, std::enable_if_t< is_atomic_v< AtomicType > > > Class Template Reference

Branch wrapper for atomic types. More...

#include <AtomicBranch.h>

Inheritance diagram for hdtree::Branch< AtomicType, std::enable_if_t< is_atomic_v< AtomicType > > >:
[legend]
Collaboration diagram for hdtree::Branch< AtomicType, std::enable_if_t< is_atomic_v< AtomicType > > >:
[legend]

Classes

class  ReadBuffer
 
class  WriteBuffer
 

Public Member Functions

 Branch (const std::string &branch_name, AtomicType *handle=nullptr)
 We don't do any more initialization except which is handled by the AbstractBranch. More...
 
void attach (Reader &f) final override
 pure virtual method for loading data from the input file More...
 
void load () final override
 Down to a type that Reader can handle. More...
 
void save () final override
 Down to a type that io::Writer can handle. More...
 
void attach (Writer &f) final override
 do NOT persist any structure for atomic types More...
 
- Public Member Functions inherited from hdtree::AbstractBranch< AtomicType >
 AbstractBranch (const std::string &branch_name, AtomicType *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 AtomicType & 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 AtomicType &val)
 Update the in-memory data object with the passed value. More...
 
AtomicType & operator* ()
 Access the in-memory data object.
 
const AtomicType & operator* () const
 Access the in-memory data opbject in a const manner.
 
AtomicType * operator-> ()
 Pointer access to the in-memory data type.
 
const AtomicType * 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 Attributes

std::unique_ptr< ReadBuffer > read_buffer_
 
std::unique_ptr< WriteBuffer > write_buffer_
 

Additional Inherited Members

- Protected Attributes inherited from hdtree::AbstractBranch< AtomicType >
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
 
AtomicType * 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 AtomicType>
class hdtree::Branch< AtomicType, std::enable_if_t< is_atomic_v< AtomicType > > >

Branch wrapper for atomic types.

See also
io::is_atomic for how we deduce if a type is atomic

Once we finally recurse down to actual fundamental ("atomic") types, we can start actually calling the file load and save methods.

Constructor & Destructor Documentation

◆ Branch()

template<typename AtomicType >
hdtree::Branch< AtomicType, std::enable_if_t< is_atomic_v< AtomicType > > >::Branch ( const std::string &  branch_name,
AtomicType *  handle = nullptr 
)
inlineexplicit

We don't do any more initialization except which is handled by the AbstractBranch.

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

Member Function Documentation

◆ attach() [1/2]

template<typename AtomicType >
void hdtree::Branch< AtomicType, std::enable_if_t< is_atomic_v< AtomicType > > >::attach ( Reader f)
inlinefinaloverridevirtual

pure virtual method for loading data from the input file

Parameters
[in]fReader to load from

Implements hdtree::AbstractBranch< AtomicType >.

◆ attach() [2/2]

template<typename AtomicType >
void hdtree::Branch< AtomicType, std::enable_if_t< is_atomic_v< AtomicType > > >::attach ( Writer f)
inlinefinaloverridevirtual

do NOT persist any structure for atomic types

The atomic types are translated into H5 DataSets in Writer::save where the types are persisted as well.

Implements hdtree::AbstractBranch< AtomicType >.

◆ load()

template<typename AtomicType >
void hdtree::Branch< AtomicType, std::enable_if_t< is_atomic_v< AtomicType > > >::load ( )
inlinefinaloverridevirtual

Down to a type that Reader can handle.

See also
Reader::load for how we read data from the file at the input branch_name to our handle.
Parameters
[in]fReader to load from

Implements hdtree::AbstractBranch< AtomicType >.

◆ save()

template<typename AtomicType >
void hdtree::Branch< AtomicType, std::enable_if_t< is_atomic_v< AtomicType > > >::save ( )
inlinefinaloverridevirtual

Down to a type that io::Writer can handle.

See also
io::Writer::save for how we write data to the file at the input branch_name from our handle.
Parameters
[in]fio::Writer to save to

Implements hdtree::AbstractBranch< AtomicType >.


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