bitrl & cuberl Documentation
Simulation engine for reinforcement learning agents
Loading...
Searching...
No Matches
bitrl::utils::io::JSONFileReader Class Referencefinal

#include <json_file_reader.h>

Inheritance diagram for bitrl::utils::io::JSONFileReader:
Collaboration diagram for bitrl::utils::io::JSONFileReader:

Public Types

using json = nlohmann::json
 
- Public Types inherited from bitrl::utils::io::FileHandlerBase< std::ifstream >
typedef std::ifstream handler_type
 

Public Member Functions

 JSONFileReader (const std::string &filename)
 
virtual void open () override final
 Attempts to open the file for reading.
 
template<typename T >
T get_value (const std::string &label) const
 Get the value specified by the label.
 
template<typename T >
T at (const std::string &label) const
 
const jsonget (const std::string &label) const
 
- Public Member Functions inherited from bitrl::utils::io::FileReaderBase
virtual ~FileReaderBase ()=default
 
bool eof () const
 Returns true if the underlying stream handler has reached the EOF.
 
- Public Member Functions inherited from bitrl::utils::io::FileHandlerBase< std::ifstream >
virtual ~FileHandlerBase ()
 Constructor.
 
FileFormats::Type get_type () const noexcept
 Returns the type of the file.
 
handler_typeget_file_stream () noexcept
 Returns the underlying file stream.
 
const handler_typeget_file_stream () const noexcept
 Returns the underlying file stream.
 
std::string get_filename () const noexcept
 Returns the filename that is used to write.
 
bool is_open () const noexcept
 Return true if and only if the file is open.
 
virtual void close ()
 Close the file. Return true if and only if the file was closed successfully false otherwise.
 

Additional Inherited Members

- Protected Member Functions inherited from bitrl::utils::io::FileReaderBase
 FileReaderBase (const std::string &file_name, FileFormats::Type t)
 Constructor.
 
- Protected Member Functions inherited from bitrl::utils::io::FileHandlerBase< std::ifstream >
 FileHandlerBase (const std::string &file_name, FileFormats::Type t)
 protected Constructor so that explicit instantiation of the class fails
 
- Protected Attributes inherited from bitrl::utils::io::FileHandlerBase< std::ifstream >
std::string file_name_
 The name of the file to write.
 
const FileFormats::Type t_
 The format of the file.
 
handler_type f_
 The low level file handler.
 

Detailed Description

Todo:
write docs

Member Typedef Documentation

◆ json

Constructor & Destructor Documentation

◆ JSONFileReader()

bitrl::utils::io::JSONFileReader::JSONFileReader ( const std::string &  filename)

Constructor

Parameters
filename

Member Function Documentation

◆ at()

template<typename T >
T bitrl::utils::io::JSONFileReader::at ( const std::string &  label) const

Returns the object at the specified label. T should be constructed using T(json data) and should be copy constructible

Parameters
label
Returns

◆ get()

const json & bitrl::utils::io::JSONFileReader::get ( const std::string &  label) const
inline
Parameters
labelThe label to get the data
Returns
Read reference to the underlying json structure that holds the data for the given label

◆ get_value()

template<typename T >
T bitrl::utils::io::JSONFileReader::get_value ( const std::string &  label) const

Get the value specified by the label.

◆ open()

void bitrl::utils::io::JSONFileReader::open ( )
finaloverridevirtual

Attempts to open the file for reading.

Reimplemented from bitrl::utils::io::FileReaderBase.


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