19#include <shared_mutex>
23#include <boost/shared_ptr.hpp>
64 FailedLoadFile(
const std::string& item,
const std::string& name,
const std::string& reason) noexcept :
exception (
fill(item, name, reason), 0) { }
71 static std::string
fill(
const std::string& item,
const std::string& name,
const std::string& reason)
noexcept;
97 static std::string
fill(
const std::string& names,
const std::string& reason)
noexcept;
123 static std::string
fill(
const char * op,
const std::string& reason)
noexcept;
146 static std::string
fill(
const char * prefix,
const std::string& name,
const std::string& reason)
noexcept;
162 CanNotCreateFile(
const char * prefix,
const char * item,
const std::string& name,
const std::string& reason) noexcept :
exception (
fill(prefix, item, name, reason), 0) { }
169 static std::string
fill(
const char * prefix,
const char * item,
const std::string& name,
const std::string& reason)
noexcept;
191 static std::string
fill(
const char * prefix,
const std::string& name)
noexcept;
209 CanNotWriteToFile(
const char * prefix,
const char * item,
const std::string& name,
const std::string& reason) noexcept :
exception (
fill(prefix, item, name, reason), 0) {}
216 static std::string
fill(
const char * prefix,
const char * item,
const std::string& name,
const std::string& reason)
noexcept;
239 static std::string
fill(
const std::string& name,
const std::string& reason)
noexcept;
265 static std::string
fill(
const char * item,
const std::string& name,
const std::string& reason)
noexcept;
316 static std::string
fill(
const OksClass &c,
const std::string& reason)
noexcept;
356 static std::string
fill(
const std::string& path,
int error_code)
noexcept;
375 void add_parents(std::string& text,
const OksFile * file, std::set<const OksFile *>& parents);
461 typedef std::map<const OksString *, Value *, SortByName>
Map;
503 Value::Map::const_iterator i =
p_aliases.find(key);
505 if(i !=
p_aliases.end())
return i->second;
599 OksKernel(
bool silence_mode =
false,
bool verbose_mode =
false,
bool profiling_mode =
false,
bool allow_repository =
true,
const char *
version =
nullptr, std::string branch_name =
"");
923 std::string
get_file_path(
const std::string& path,
const OksFile * parent_file = 0,
bool strict_paths =
true)
const;
988 static std::string
get_tmp_file(
const std::string& file_name);
1000 void get_includes(
const std::string& file_name, std::set< std::string >& includes,
bool use_repository_name =
false);
1310 void reload_data(std::set<OksFile *>& files,
bool allow_schema_extension =
true);
1330 OksFile *
new_data(
const std::string& name,
const std::string& logical_name =
"",
const std::string& type =
"");
1348 void save_data(
OksFile * file_h,
bool ignore_bad_objects =
false,
OksFile * true_file_h =
nullptr,
bool force_defaults =
false);
1560 commit_repository(
const std::string& comments,
const std::string& credentials =
"");
1637 std::list<std::string>
1645 std::list<std::string>
1661 std::vector<OksRepositoryVersion>
1675 std::vector<OksRepositoryVersion>
1689 std::vector<OksRepositoryVersion>
1708 static const char *
get_cwd();
2090 void k_copy_repository(
const std::string& source,
const std::string& destination);
2107 void k_checkout_repository(
const std::string& param,
const std::string& val,
const std::string& branch);
Failed to authenticate user.
virtual ~AuthenticationFailure() noexcept
AuthenticationFailure(const std::string &reason) noexcept
virtual ~CanNotBackupFile() noexcept
CanNotBackupFile(const std::string &name, const exception &reason) noexcept
static std::string fill(const std::string &name, const std::string &reason) noexcept
CanNotCreateFile(const char *prefix, const char *item, const std::string &name, const std::string &reason) noexcept
CanNotCreateFile(const char *prefix, const char *item, const std::string &name, const exception &reason) noexcept
virtual ~CanNotCreateFile() noexcept
static std::string fill(const char *prefix, const char *item, const std::string &name, const std::string &reason) noexcept
virtual ~CanNotCreateRepositoryDir() noexcept
CanNotCreateRepositoryDir(const char *prefix, const std::string &name) noexcept
static std::string fill(const char *prefix, const std::string &name) noexcept
virtual ~CanNotOpenFile() noexcept
CanNotOpenFile(const char *prefix, const std::string &name, const std::string &reason) noexcept
static std::string fill(const char *prefix, const std::string &name, const std::string &reason) noexcept
Failed to set active file.
CanNotSetActiveFile(const char *item, const std::string &name, const std::string &reason) noexcept
virtual ~CanNotSetActiveFile() noexcept
CanNotSetActiveFile(const char *item, const std::string &name, const exception &reason) noexcept
static std::string fill(const char *item, const std::string &name, const std::string &reason) noexcept
Failed move item to file.
CanNotSetFile(const OksClass *c, const OksObject *o, const OksFile &file, const std::string &reason) noexcept
static std::string fill(const OksClass *c, const OksObject *o, const OksFile &file, const std::string &reason) noexcept
CanNotSetFile(const OksClass *c, const OksObject *o, const OksFile &file, const exception &reason) noexcept
virtual ~CanNotSetFile() noexcept
CanNotWriteToFile(const char *prefix, const char *item, const std::string &name, const exception &reason) noexcept
CanNotWriteToFile(const char *prefix, const char *item, const std::string &name, const std::string &reason) noexcept
static std::string fill(const char *prefix, const char *item, const std::string &name, const std::string &reason) noexcept
virtual ~CanNotWriteToFile() noexcept
CannotAddClass(const OksClass &c, const exception &reason) noexcept
static std::string fill(const OksClass &c, const std::string &reason) noexcept
CannotAddClass(const OksClass &c, const std::string &reason) noexcept
virtual ~CannotAddClass() noexcept
static std::string fill(const std::string &path, int error_code) noexcept
CannotResolvePath(const std::string &path, int error_code) noexcept
virtual ~CannotResolvePath() noexcept
virtual ~FailedLoadFile() noexcept
static std::string fill(const std::string &item, const std::string &name, const std::string &reason) noexcept
FailedLoadFile(const std::string &item, const std::string &name, const exception &reason) noexcept
FailedLoadFile(const std::string &item, const std::string &name, const std::string &reason) noexcept
FailedReloadFile(const std::string &names, const exception &reason) noexcept
static std::string fill(const std::string &names, const std::string &reason) noexcept
FailedReloadFile(const std::string &names, const std::string &reason) noexcept
virtual ~FailedReloadFile() noexcept
static NotifyFN create_notify_fn
static NotifyFN delete_notify_fn
static ChangeNotifyFN change_notify_fn
std::map< const char *, OksClass *, SortStr > Map
ChangeType
Information about class property changes.
Provides interface to the OKS XML schema and data files.
std::map< const std::string *, OksFile *, SortByName > Map
Provides interface to the OKS kernel.
bool p_allow_duplicated_classes
OksObject::notify_obj p_change_object_notify_fn
OksFile * p_active_schema
void define(OksObject *o)
OksFile * get_active_schema() const
Get active OKS schema file.
static const std::string & get_repository_mapping_dir()
Get OKS repository name.
std::mutex p_objects_mutex
OksFile * get_active_data() const
Get active OKS data file.
void subscribe_change_object(OksObject::notify_obj, void *)
Subscribe on object changing.
static void reset_cwd()
Reset current working dir in case of chdir() call.
const std::string & get_user_repository_root() const
Get user OKS repository root.
void k_save_schema(OksFile *, bool force=false, OksFile *=0, const OksClass::Map *=0)
void subscribe_delete_object(OksObject::notify_obj, void *)
Subscribe on object deleting.
OksFile * load_file(const std::string &name, bool bind=true)
Load OKS database file.
static std::string & get_host_name()
Get hostname of given process.
static std::string & get_user_name()
Get username of given process.
bool get_profiling_mode() const
Get status of profiling mode. The method returns true, if the profiling mode is switched 'On'....
void restore_preload_file_info()
bool is_dangling(OksClass *class_ptr) const
Check pointer on oks class.
std::list< std::string > get_repository_versions_diff(const std::string &sha1, const std::string &sha2)
OksFile * load_data(const std::string &name, bool bind=true)
Load OKS data file.
bool p_allow_duplicated_objects
void k_set_active_data(OksFile *)
Set active OKS data file.
static bool check_read_only(OksFile *f)
Check if the OKS file is read-only.
void k_rename_repository_file(OksFile *file_h, const std::string &new_name)
static bool p_use_strict_repository_paths
void update_repository(const std::string &hash_val, RepositoryUpdateType update_type)
Update user repository files from origin by hash.
static std::mutex p_parallel_out_mutex
void remove_repository_dir(const std::string &dir)
Remove repository search directory.
void get_modified_files(std::set< OksFile * > &mfs, std::set< OksFile * > &rfs, const std::string &version)
Get modified data files.
const OksFile::Map & data_files() const
Get all data files.
std::string p_repository_version
void k_check_bind_classes_status() const noexcept
void save_as_data(const std::string &new_name, OksFile *file_h)
Save OKS data file under new name.
std::list< std::string > get_repository_unmerged_files()
void create_lists_of_updated_data_files(std::list< OksFile * > **updated, std::list< OksFile * > **removed) const
Get modified data files.
OksFile * new_data(const std::string &name, const std::string &logical_name="", const std::string &type="")
Create OKS data file.
static std::string p_repository_root
std::list< OksObject * > * create_list_of_data_objects(OksFile *) const
Creates list of objects which belong to given file.
void set_active_schema(OksFile *file_h)
Set active OKS schema file.
void k_close_dangling_includes()
Close files which lost their parent.
OksFile * find_data_file(const std::string &s) const
Finds OKS data file.
std::time_t p_repository_checkout_ts
void k_rename_schema(OksFile *, const std::string &short_name, const std::string &long_name)
bool is_user_repository_created() const
std::map< std::string, T > map_str_t
void registrate_all_classes(bool skip_registered=false)
The method rebuilds all classes taking into account inheritance.
void k_close_schema(OksFile *)
void set_user_repository_root(const std::string &path, const std::string &version="")
Set user OKS repository root.
std::string p_bind_objects_status
const std::string & get_bind_classes_status() const noexcept
Return status of oks classes binding.
void add_data_file(OksFile *)
const OksObject::Set & objects() const
Get objects.
OksFile::Map p_schema_files
OksFile * create_file_info(const std::string &short_file_name, const std::string &file_name)
Creates OKS file descriptor.
OksFile * k_load_file(const std::string &name, bool bind, const OksFile *parent, OksPipeline *pipeline)
bool get_verbose_mode() const
Get status of verbose mode. The method returns true, if the verbose mode is switched 'On'.
void subscribe_change_class(void(*f)(OksClass *, OksClass::ChangeType, const void *))
Subscribe on class changing.
bool get_test_duplicated_objects_via_inheritance_mode() const
Get status of test inherited duplicated objects mode. The method returns true, if the mode is switche...
std::string create_user_repository_dir()
OksKernel(bool silence_mode=false, bool verbose_mode=false, bool profiling_mode=false, bool allow_repository=true, const char *version=nullptr, std::string branch_name="")
Constructor to build OksKernel object.
void backup_schema(OksFile *pf, const char *suffix=".bak")
Backup OKS schema file.
std::string get_file_path(const std::string &path, const OksFile *parent_file=0, bool strict_paths=true) const
Calculates full path to file.
void reload_data(std::set< OksFile * > &files, bool allow_schema_extension=true)
Reload OKS data files.
void k_rename_data(OksFile *, const std::string &short_name, const std::string &long_name)
friend std::ostream & operator<<(std::ostream &, OksKernel &)
OksObject::notify_obj p_delete_object_notify_fn
bool get_allow_duplicated_objects_mode() const
Get status of duplicated objects mode. The method returns true, if the duplicated objects mode is swi...
std::list< std::string > p_repository_dirs
void subscribe_delete_class(void(*f)(OksClass *))
Subscribe on class destroying.
void k_close_data(OksFile *, bool)
void k_set_active_schema(OksFile *file_h)
Set active OKS schema file. Non thread-safe version of the set_active_schema() method;.
void create_lists_of_updated_schema_files(std::list< OksFile * > **updated, std::list< OksFile * > **removed) const
Get modified schema files.
static void set_use_strict_repository_paths(bool flag)
Set flag to use strict-repository-paths check.
void remove_user_repository_dir()
const OksClass::Map & classes() const
Get classes.
std::vector< OksRepositoryVersion > get_repository_versions(bool skip_irrelevant, const std::string &command_line)
Return repository versions.
OksFile * find_schema_file(const std::string &s) const
Finds OKS schema file.
std::vector< OksRepositoryVersion > get_repository_versions_by_date(bool skip_irrelevant=true, const std::string &since="", const std::string &until="")
Return repository versions between timestamps.
void set_allow_duplicated_objects_mode(const bool b)
Set status of duplicated objects mode. To switch 'On'/'Off' use the method's parameter:
static std::string p_repository_mapping_dir
OksFile * find_file(const std::string &s, const OksFile::Map &files) const
std::vector< OksFile * > p_preload_added_files
void * p_delete_object_notify_param
static void set_skip_string_range(const bool b)
Set status of string range validator. To switch 'On'/'Off' use the method's parameter:
std::time_t p_repository_update_ts
void undefine(OksObject *o)
static int p_threads_pool_size
void k_load_includes(const OksFile &, OksPipeline *)
bool p_user_repository_root_created
void tag_repository(const std::string &tag)
Tag current state of repository.
void backup_data(OksFile *pf, const char *suffix=".bak")
Backup OKS data file.
std::shared_mutex & get_mutex()
Return OKS kernel mutex.
void remove_schema_file(OksFile *)
void set_silence_mode(const bool b)
Set status of silence mode. To switch 'On'/'Off' use the method's parameter:
void get_updated_repository_files(std::set< std::string > &updated, std::set< std::string > &added, std::set< std::string > &removed)
Get repository modified schema files.
void unset_repository_created()
Set repository created flag to false to avoid created repository removal in destructor;.
void subscribe_create_object(OksObject::notify_obj cb_f, void *parameter)
Subscribe on object creation.
static bool get_skip_string_range()
Get status of string range validator.
void k_copy_repository(const std::string &source, const std::string &destination)
void save_schema(OksFile *file_h, bool force=false, OksFile *true_file_h=0)
Save OKS schema file.
void set_profiling_mode(const bool b)
Set status of profiling mode. To switch 'On'/'Off' use the method's parameter:
std::string p_bind_classes_status
std::mutex p_objects_refs_mutex
bool get_allow_duplicated_classes_mode() const
Get status of duplicated classes mode. The method returns true, if the duplicated classes mode is swi...
size_t number_of_classes() const
Get number of classes.
std::time_t get_repository_checkout_ts() const
Return repository checkout timestamp.
static unsigned long p_count
OksFile * k_load_schema(const std::string &, const OksFile *)
void close_all_data()
Close all OKS data files.
std::string read_repository_version()
Read and return current repository version.
bool test_parent(OksFile *file, OksFile::IMap::iterator &i)
std::string p_user_repository_root
static bool p_skip_string_range
void k_remove(OksClass *)
void save_data(OksFile *file_h, bool ignore_bad_objects=false, OksFile *true_file_h=nullptr, bool force_defaults=false)
Save OKS data file.
void set_test_duplicated_objects_via_inheritance_mode(const bool b)
Set status of test inherited duplicated objects mode. To switch 'On'/'Off' use the method's parameter...
void bind_objects()
Bind oks objects.
static const std::string & get_repository_root()
Get OKS repository root.
void * p_change_object_notify_param
void commit_repository(const std::string &comments, const std::string &credentials="")
Commit user modifications into repository.
size_t number_of_objects() const
Get number of objects.
void clear_preload_file_info()
const std::string & get_repository_version()
void save_as_schema(const std::string &name, OksFile *file_h)
Save OKS schema file under new name.
void close_data(OksFile *file_h, bool unbind_objects=true)
Close OKS data file.
const std::string & get_bind_objects_status() const noexcept
Return status of oks objects binding.
static std::string get_tmp_file(const std::string &file_name)
Generates temporal file name.
static const char * get_cwd()
OksFile * k_load_data(const std::string &, bool, const OksFile *, OksPipeline *)
OksFile * new_schema(const std::string &name)
Create OKS schema file.
std::vector< OksRepositoryVersion > get_repository_versions_by_hash(bool skip_irrelevant=true, const std::string &sha1="", const std::string &sha2="")
Return repository versions between hash keys.
std::shared_mutex p_kernel_mutex
bool p_test_duplicated_objects_via_inheritance
void set_allow_duplicated_classes_mode(const bool b)
Set status of duplicated classes mode. To switch 'On'/'Off' use the method's parameter:
void save_all_schema()
Save all OKS schema files.
OksObject::notify_obj p_create_object_notify_fn
std::list< OksClass * > * create_list_of_schema_classes(OksFile *) const
Creates list of classes which belong to given file.
void save_all_data(bool force_defaults=false)
Save all OKS data files.
void add_schema_file(OksFile *)
static const char * GetVersion()
Get OKS version. The method returns string containing CVS tag and date of OKS build.
void subscribe_create_class(void(*f)(OksClass *))
Subscribe on class creation.
OksClass * find_class(const std::string &class_name) const
Find class by name (C++ string).
bool get_silence_mode() const
Get status of silence mode. The method returns true, if the silence mode is switched 'On'....
void close_schema(OksFile *file_h)
Close OKS schema file.
void remove_data_file(OksFile *)
const std::list< std::string > & get_repository_dirs() const
Get repository search directories.
void set_verbose_mode(const bool b)
Set status of verbose mode. To switch 'On'/'Off' use the method's parameter:
OksProfiler * GetOksProfiler() const
bool k_preload_includes(OksFile *file_h, std::set< OksFile * > &new_files, bool allow_schema_extension)
std::shared_mutex p_schema_mutex
void close_all_schema()
Close all OKS schema files.
static std::string & get_domain_name()
Get domain name of host.
void set_active_data(OksFile *file_h)
Set active OKS data file.
OksFile * load_schema(const std::string &name, const OksFile *parent=0)
Load OKS schema file.
void unbind_all_rels(const OksObject::FSet &rm_objs, OksObject::FSet &updated) const
Unbind all references on given oks objects. The method unbinds all relationships referencing given ob...
std::string insert_repository_dir(const std::string &dir, bool push_back=true)
Insert repository search directory.
void k_checkout_repository(const std::string ¶m, const std::string &val, const std::string &branch)
Check out repository files into local user directory.
const OksFile::Map & schema_files() const
Get all schema files.
OksFile::Map p_data_files
std::map< const OksFile *, OksFile * > p_preload_file_info
void get_all_classes(const std::vector< std::string > &names_in, ClassSet &classes_out) const
The method searches all classes including subclasses for given names.
void * p_create_object_notify_param
void get_includes(const std::string &file_name, std::set< std::string > &includes, bool use_repository_name=false)
Opens file and reads its shallow includes.
bool p_user_repository_root_inited
void k_save_data(OksFile *, bool=false, OksFile *=nullptr, const OksObject::FSet *=nullptr, bool force_defaults=false)
OksObject describes instance of OksClass.
std::set< OksObject *, std::less< OksObject * > > Set
std::unordered_set< OksObject *, oks::hash_obj_ptr, oks::equal_obj_ptr > FSet
void(*) notify_obj(OksObject *, void *)
Cannot commit, checkout or release files.
RepositoryOperationFailed(const char *op, const std::string &reason) noexcept
RepositoryOperationFailed(const char *op, const exception &reason) noexcept
virtual ~RepositoryOperationFailed() noexcept
static std::string fill(const char *op, const std::string &reason) noexcept
caught dunedaq::conffwk::Exception exception
std::ostream & log_timestamp(__LogSeverity__ severity=Log)
double get_time_interval(const timeval *t1, const timeval *t2)
std::unordered_set< const OksClass *, oks::hash_class_ptr, oks::equal_class_ptr > ClassSet
void add_parents(std::string &text, const OksFile *file, std::set< const OksFile * > &parents)
std::string m_error_string
std::list< std::string > m_errors
void add_error(const OksFile &file, std::exception &ex)
bool operator()(const OksString *s1, const OksString *s2) const
Value(OksString *n, const OksClass *p)
std::map< const OksString *, Value *, SortByName > Map
const OksClass * class_ptr
The struct OksAliasTable is used to support aliases.
void add_value(OksString *vn, const OksClass *vp)
const Value * get(const char *key) const
void add_key(OksString *)
const Value * get(const OksString *key) const
the structure to pass common parameters to various read() methods of OksData and OksObject class
std::string m_commit_hash
std::vector< std::string > m_files