26 #include <pni/core/types.hpp>
27 #include <pni/core/utilities.hpp>
41 using pni::core::string;
42 using pni::core::exception;
55 template<nximp_code IMPID>
class nxfile
76 nxfile(
const file_type &file):_imp(file._imp) { }
88 explicit nxfile(imp_type &&imp):_imp(
std::move(imp)){ }
96 if((_imp.is_valid())&&(!_imp.is_readonly()))
99 r.attributes.template create<string>(
"file_update_time",
true)
111 if(
this == &f)
return *
this;
124 if(
this == &f)
return *
this;
126 _imp = std::move(f._imp);
145 static file_type
open_file(
const string &n,
bool ro=
true)
147 return file_type(imp_type::open(n,ro));
171 file_type file = file_type(imp_type::create(n,ow,ssize));
173 auto root_group = file.
root();
176 root_group.attributes.template
177 create<string>(
"NX_class",
true).
write(
string(
"NXroot"));
178 root_group.attributes.template
180 root_group.attributes.template
182 root_group.attributes.template create<string>(
"file_name",
true).
write(n);
185 root_group.attributes.template
186 create<string>(
"NeXus_version",
true).
write(
string(
"4.3.0"));
211 return create_files(n,0,ow);
246 if((this->
is_valid())&&(!this->is_readonly()))
249 r.attributes.template create<string>(
"file_update_time",
true)
275 return group_type(group_imp_type(_imp.root()));
288 return _imp.is_valid();
static file_type create_file(const string &n, bool ow=false)
create single file
Definition: nxfile.hpp:209
static pni::core::string get_date_time_str()
date-time now
Definition: nxdate_time.cpp:65
static file_type create_files(const string &n, ssize_t ssize, bool ow=false)
create file family
Definition: nxfile.hpp:169
implementation map
Definition: nximp_map.hpp:50
nexus object traits
Definition: nxobject_traits.hpp:44
void flush() const
flush the file
Definition: nxfile.hpp:221
nxfile(file_type &&f)
move constructor
Definition: nxfile.hpp:82
imp_type _imp
implementation instance
Definition: nxfile.hpp:64
bool is_readonly() const
check read only
Definition: nxfile.hpp:233
file_type & operator=(const file_type &f)
copy assignment operator
Definition: nxfile.hpp:109
static file_type open_file(const string &n, bool ro=true)
open file
Definition: nxfile.hpp:145
Definition: cbf_reader.hpp:41
nximp_map< IMPID >::file_imp imp_type
implementation type
Definition: nxfile.hpp:59
nxfile< IMPID > file_type
Nexus file type.
Definition: nxfile.hpp:61
bool is_valid(const OTYPE &o) noexcept
visitor checking object validity
Definition: is_valid.hpp:53
File object.
Definition: nxfile.hpp:55
void close()
close the file
Definition: nxfile.hpp:244
nxfile()
default constructor
Definition: nxfile.hpp:70
nxobject_trait< IMPID >::group_type root() const
get root group
Definition: nxfile.hpp:270
~nxfile()
destructor
Definition: nxfile.hpp:94
bool is_valid() const noexcept
check validity
Definition: nxfile.hpp:286
nxfile(imp_type &&imp)
implemenetation move constructor
Definition: nxfile.hpp:88
void write(const OTYPE< IMPID > &o, const ATYPE &a)
write data to an attribute or field
Definition: write.hpp:61
file_type & operator=(file_type &&f)
move assignment operator
Definition: nxfile.hpp:122
nxfile(const file_type &file)
copy constrcutor
Definition: nxfile.hpp:76