DUNE-DAQ
DUNE Trigger and Data Acquisition software
|
Provides interface to the OKS XML schema and data files. More...
#include <file.hpp>
Classes | |
struct | SortByName |
Public Types | |
enum | Mode { ReadOnly , ReadWrite } |
enum | FileStatus { FileNotModified , FileModified , FileWasNotSaved , FileRemoved } |
typedef std::map< const std::string *, OksFile *, SortByName > | Map |
typedef std::unordered_set< OksFile *, oks::hash_file_ptr, oks::equal_file_ptr > | Set |
typedef std::unordered_map< OksFile *, Set, oks::hash_file_ptr, oks::equal_file_ptr > | IMap |
Public Member Functions | |
void | lock () |
Lock OKS file. | |
void | unlock () |
Unlock OKS file. | |
void | add_include_file (const std::string &name) |
Add include file. | |
void | remove_include_file (const std::string &name) |
Remove include file. | |
void | rename_include_file (const std::string &from, const std::string &to) |
Rename include file. | |
void | add_comment (const std::string &text, const std::string &author) |
Add new comment to file. | |
void | modify_comment (const std::string &creation_time, const std::string &text, const std::string &author) |
void | remove_comment (const std::string &creation_time) |
Modify existing comment. | |
const std::map< std::string, oks::Comment * > & | get_comments () const |
void | set_logical_name (const std::string &name) |
Set logical name of file. | |
void | set_type (const std::string &type) |
Set file type. | |
const std::string & | get_short_file_name () const |
const std::string & | get_full_file_name () const |
bool | is_repository_file () const |
Get information about repository, the file belongs to. | |
const std::string & | get_repository_name () const |
Get name of file inside repository. | |
const std::string & | get_well_formed_name () const |
Get well-formed file name. | |
const std::string & | get_lock_file () const |
const std::string & | get_logical_name () const |
const std::string & | get_type () const |
const std::string & | get_oks_format () const |
long | get_number_of_items () const |
long | get_size () const |
const std::string & | get_created_by () const |
const boost::posix_time::ptime | get_creation_time () const |
const std::string & | get_created_on () const |
const std::string & | get_last_modified_by () const |
const boost::posix_time::ptime | get_last_modification_time () const |
const std::string & | get_last_modified_on () const |
bool | is_locked () const |
Return lock status of OKS file. | |
bool | is_updated () const |
Return update status of OKS file. | |
bool | is_read_only () const |
Return read-only status of OKS file. | |
const std::list< std::string > & | get_include_files () const |
Get directly include files. | |
void | get_all_include_files (const OksKernel *kernel, std::set< OksFile * > &out) |
Get all include files. | |
FileStatus | get_status_of_file () const |
Return update status of file. | |
void | update_status_of_file (bool update_local=true, bool update_repository=true) |
Update status of file. | |
bool | get_lock_string (std::string &info) const |
Return lock status of OKS file and if the file is locked, get information string about process which locked the file. | |
bool | compare (const char *name) const |
Compare with another file. | |
const OksFile * | get_parent () const |
Return parent including given file. | |
OksFile * | check_parent (const OksFile *parent_h) |
Set given parent, if this file is not yet included. | |
~OksFile () noexcept | |
Static Public Member Functions | |
static void | set_nolock_mode (bool nl) |
static bool | compare (const char *file1_name, const char *file2_name) |
Compare two files. | |
Private Member Functions | |
OksFile (const std::string &, const std::string &, const std::string &, const std::string &, OksKernel *) | |
OksFile & | operator= (const OksFile &) |
OksFile (const OksFile &f) | |
OksFile (std::shared_ptr< OksXmlInputStream >, const std::string &, const std::string &, OksKernel *) | |
void | write (OksXmlOutputStream &) |
void | set_updated () |
void | rename (const std::string &short_name, const std::string &full_name) |
void | rename (const std::string &full_name) |
void | create_lock_name () |
void | init_lock_name () const |
void | check_repository () |
std::string | make_repository_name () const |
oks::Comment * | get_comment (const std::string &creation_time) noexcept |
void | clear_comments () noexcept |
std::list< std::string >::iterator | find_include_file (const std::string &) |
Private Attributes | |
std::string | p_short_name |
std::string | p_full_name |
std::string | p_repository_name |
std::string | p_logical_name |
std::string | p_type |
std::string | p_oks_format |
long | p_number_of_items |
long | p_size |
std::string | p_created_by |
boost::posix_time::ptime | p_creation_time |
std::string | p_created_on |
std::string | p_last_modified_by |
boost::posix_time::ptime | p_last_modification_time |
std::string | p_last_modified_on |
Mode | p_open_mode |
std::shared_ptr< boost::interprocess::file_lock > | p_lock |
std::string | p_lock_file_name |
bool | p_is_updated |
bool | p_is_read_only |
std::list< std::string > | p_list_of_include_files |
time_t | p_last_modified |
time_t | p_repository_last_modified |
std::map< std::string, oks::Comment * > | p_comments |
bool | p_is_on_disk |
const OksFile * | p_included_by |
OksKernel * | p_kernel |
Static Private Attributes | |
static bool | p_nolock_mode = false |
static const char | xml_file_header [] = "<?xml version=\"1.0\" encoding=\"ASCII\"?>" |
static const char | xml_schema_file_dtd [] |
static const char | xml_data_file_dtd [] |
static const char | xml_info_tag [] = "info" |
static const char | xml_include_tag [] = "include" |
static const char | xml_file_tag [] = "file" |
static const char | xml_comments_tag [] = "comments" |
static const char | xml_comment_tag [] = "comment" |
Friends | |
class | OksKernel |
class | OksClass |
class | OksObject |
struct | OksLoadObjectsJob |
Provides interface to the OKS XML schema and data files.
An object of this class is used to read/write header part of OKS XML file, includes and comments. It allows to set update lock on file creating .oks-lock-$filename file: see lock() and unlock() methods. Also, the class provides methods to get many other properties of the file, e.g. status, access mode, repository information, number of stored items, size, etc.
std::unordered_map<OksFile *, Set, oks::hash_file_ptr, oks::equal_file_ptr> dunedaq::oks::OksFile::IMap |
std::map<const std::string *, OksFile *, SortByName> dunedaq::oks::OksFile::Map |
std::unordered_set<OksFile *, oks::hash_file_ptr, oks::equal_file_ptr> dunedaq::oks::OksFile::Set |
Enumerator | |
---|---|
FileNotModified | |
FileModified | |
FileWasNotSaved | |
FileRemoved |
|
noexcept |
|
private |
Definition at line 252 of file file.cpp.
|
inlineprivate |
|
private |
Definition at line 344 of file file.cpp.
void dunedaq::oks::OksFile::add_comment | ( | const std::string & | text, |
const std::string & | author ) |
Add new comment to file.
The method allows to add text description to the file.
text | the description; must not be empty |
author | the author's description, e.g. first and last names, the e-mail address, etc. |
In | case of problems (e.g. empty text) the method throws oks::exception. |
Definition at line 669 of file file.cpp.
void dunedaq::oks::OksFile::add_include_file | ( | const std::string & | name | ) |
Add include file.
The method adds include file to given one. To load included file it is necessary to save the file and load it again.
name | name of include file to be added |
In | case of problems (e.g. cannot lock file) the method throws oks::exception. |
Definition at line 1194 of file file.cpp.
Set given parent, if this file is not yet included.
parent_h | parent file |
|
private |
Definition at line 915 of file file.cpp.
|
privatenoexcept |
Definition at line 280 of file file.cpp.
|
static |
Compare two files.
file1_name | name of first file |
file2_name | name of second file |
In | case of problems the method throws oks::exception. |
Definition at line 1514 of file file.cpp.
|
inline |
Compare with another file.
name | name of file to compare with |
In | case of problems the method throws oks::exception. |
Definition at line 708 of file file.hpp.
|
private |
|
private |
Definition at line 1172 of file file.cpp.
void dunedaq::oks::OksFile::get_all_include_files | ( | const OksKernel * | kernel, |
std::set< OksFile * > & | out ) |
Get all include files.
kernel | OKS kernel |
out | set of all files included explicitly and implicitly by given file |
Definition at line 1466 of file file.cpp.
|
privatenoexcept |
Definition at line 705 of file file.cpp.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
bool dunedaq::oks::OksFile::get_lock_string | ( | std::string & | info | ) | const |
Return lock status of OKS file and if the file is locked, get information string about process which locked the file.
The method method also works for files locked by external process contrary to the is_locked() method.
info | out parameter containing info about process locked this file |
Definition at line 984 of file file.cpp.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
OksFile::FileStatus dunedaq::oks::OksFile::get_status_of_file | ( | ) | const |
Return update status of file.
The file can be in one of the following states:
Definition at line 1413 of file file.cpp.
|
inline |
|
inline |
Get well-formed file name.
In particular, strip repository root prefix.
|
inlineprivate |
Definition at line 798 of file file.hpp.
|
inline |
|
inline |
bool dunedaq::oks::OksFile::is_repository_file | ( | ) | const |
Get information about repository, the file belongs to.
If the global database repository is set (e.g. TDAQ_DB_REPOSITORY is defined) and the file is stored on it, the method returns GlobalRepository. If the user database repository is set (e.g. TDAQ_DB_USER_REPOSITORY is defined) and the file is stored on it, the method returns UserRepository. Otherwise file does not belong to any repository and the method returns NoneRepository.
The file's repository can be changed using OksKernel::checkout() and OksKernel::release() methods: they move file between global and user repositories. If file is removed in global repository, while it is stored on the user one, its repository should be changed using unset_repository() method.
|
inline |
void dunedaq::oks::OksFile::lock | ( | ) |
Lock OKS file.
The method locks OKS file: for file .../file.xml the lock file .../.oks-file.xml is created. The lock file contains information about process locking it and remains exclusive while process created it is alive.
In | case of problems (e.g. file was already locked) the method throws oks::exception. |
Definition at line 1012 of file file.cpp.
|
private |
Definition at line 1378 of file file.cpp.
void dunedaq::oks::OksFile::modify_comment | ( | const std::string & | creation_time, |
const std::string & | text, | ||
const std::string & | author ) |
/brief Modify existing comment.
The method allows to modify already existing comment.
/param creation_time the time-stamp when comment was created ( returned by get_comments() ) /param text the description; must not be empty /param author the author's description, e.g. first and last names, the e-mail address, etc.
In | case of problems (e.g. empty text, cannot find comment created at given time) the method throws oks::exception. |
Definition at line 712 of file file.cpp.
Definition at line 296 of file file.cpp.
void dunedaq::oks::OksFile::remove_comment | ( | const std::string & | creation_time | ) |
Modify existing comment.
The method allows to erase already existing comment.
creation_time | the timestamp when comment was created ( returned by get_comments() ) |
In | case of problems (e.g. cannot find comment created at given time, cannot lock file) the method throws oks::exception. |
Definition at line 746 of file file.cpp.
void dunedaq::oks::OksFile::remove_include_file | ( | const std::string & | name | ) |
Remove include file.
The method removes include file from given one. The name of the file to be removed has to be exactly the same as passed to the add_include_file() or as it appears in the include section of OKS xml file. To unload included file it is necessary to save the file and load it again.
name | name of include file to be removed |
In | case of problems (e.g. cannot lock file, include does not exist) the method throws oks::exception. |
Definition at line 1223 of file file.cpp.
|
private |
Definition at line 1458 of file file.cpp.
|
private |
Definition at line 1449 of file file.cpp.
void dunedaq::oks::OksFile::rename_include_file | ( | const std::string & | from, |
const std::string & | to ) |
Rename include file.
The method renames already included file. To re-load new file it is necessary to save the file and load it again.
from | exact name of already included file |
to | new name of include |
In | case of problems (e.g. cannot lock file, no such include file) the method throws oks::exception. |
Definition at line 1251 of file file.cpp.
void dunedaq::oks::OksFile::set_logical_name | ( | const std::string & | name | ) |
Set logical name of file.
The logical name can be associated by user with the file, e.g. to describe its purpose.
name | the logical name |
In | case of problems (e.g. cannot lock file) the method throws oks::exception. |
Definition at line 1279 of file file.cpp.
|
inlinestatic |
Definition at line 385 of file file.hpp.
void dunedaq::oks::OksFile::set_type | ( | const std::string & | type | ) |
Set file type.
The type can be associated by user with the file, e.g. to describe its contents.
name | the type |
In | case of problems (e.g. cannot lock file) the method throws oks::exception. |
Definition at line 1296 of file file.cpp.
void dunedaq::oks::OksFile::unlock | ( | ) |
Unlock OKS file.
The method removes lock created by lock() method. check_repository
In | case of problems (e.g. cannot unlink lock file) the method throws oks::exception. |
Definition at line 1143 of file file.cpp.
void dunedaq::oks::OksFile::update_status_of_file | ( | bool | update_local = true, |
bool | update_repository = true ) |
Update status of file.
update_local | if true, update last-modified timestamp of local file |
update_repository | if true, update last-modified timestamp of repository file |
Definition at line 1391 of file file.cpp.
|
private |
Definition at line 767 of file file.cpp.
|
friend |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
staticprivate |
|
private |
|
private |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |