KIDS  ver-0.0.1
KIDS : Kernel Integrated Dynamics Simulator
Loading...
Searching...
No Matches
Kernel_Dump_DataSet.cpp
Go to the documentation of this file.
2
3#include "kids/hash_fnv1a.h"
4#include "kids/macro_utils.h"
5
6namespace PROJECT_NS {
7
8const std::string Kernel_Dump_DataSet::getName() { return "Kernel_Dump_DataSet"; }
9
11
12void Kernel_Dump_DataSet::setInputParam_impl(std::shared_ptr<Param>& PM) {
13 fn = PM->get_string("dump", LOC(), "final");
14 hdlr_str = PM->get_string("handler", LOC());
15 directory = PM->get_string("directory", LOC());
16 assert(directory != "");
17}
18
20 if (hdlr_str == "sampling") {
21 try {
22 std::ofstream ofs{utils::concat(directory, "/samp", stat.icalc, ".ds")};
23 _dataset->dump(ofs);
24 ofs.close();
25 } catch (std::runtime_error& e) { throw kids_error(fn); }
26 }
27 return stat;
28}
29
31 if (fn == "" || fn == "null") return stat;
32 try {
33 std::ofstream ofs{utils::concat(directory, "/", fn, stat.icalc, ".ds")};
34 _dataset->dump(ofs);
35 ofs.close();
36 } catch (std::runtime_error& e) { throw kids_error(fn); }
37 return stat;
38}
39
40}; // namespace PROJECT_NS
this file provides Kernel_Dump_DataSet class enabling dump dataset.
virtual const std::string getName()
Get the name of the kernel.
virtual void setInputParam_impl(std::shared_ptr< Param > &PM)
Virtual function to set input parameters for the kernel implementation.
std::string fn
filename (stamp) for dumping
std::string directory
path for dumping
virtual Status & executeKernel_impl(Status &stat)
Virtual function to execute the kernel implementation.
virtual int getType() const
Get the type of the kernel.
virtual Status & initializeKernel_impl(Status &stat)
Virtual function to initialize the kernel implementation.
std::string hdlr_str
handler type specifier
std::shared_ptr< DataSet > _dataset
Shared pointer to the DataSet object associated with this kernel.
Definition Kernel.h:278
#define LOC()
show the location information for debug
Definition fmt.h:49
#define FUNCTION_NAME
Definition macro_utils.h:9
< http://warp.povusers.org/FunctionParser/fparser.html
Definition Context.h:39
std::basic_string< CharT > concat(const separator_t< CharT > &sep, Args &&... seq)
Definition concat.h:242
constexpr uint32_t hash(const char *str)
Definition hash_fnv1a.h:12