32 #define CUTS_I_CUT_H 1 42 #include <boost/cstdlib.hpp> 43 #include <boost/shared_ptr.hpp> 55 class service_manager;
68 virtual operator bool()
const = 0;
70 virtual bool match(
const std::type_info * tit_)
const = 0;
78 const T &
get()
const {
81 "No referenced data !" 88 virtual bool match(
const std::type_info * tit_)
const {
91 void set(
const T & obj) {
95 virtual operator bool()
const {
115 const std::type_info *
_ti;
125 void set_name(
const std::string & a_name);
128 const std::string &
get_name()
const;
160 <<
"adding user data of type '" <<
typeid(T).name() <<
"'...");
174 "Cut '" << (
has_name()?
get_name():
"?") <<
"' does not reference any user data of type '" <<
typeid(T).name() <<
"' !");
175 const std::type_info & ti =
typeid(T);
176 return _user_data_.get()->match(&ti);
185 "Invalid request on user data for cut named '" << (
has_name()?
get_name():
"?") <<
"' !");
189 "Invalid cast for reference data in cut named '" << (
has_name()?
get_name():
"?") <<
"' !");
197 const std::type_info & ti =
typeid(T);
207 const std::type_info & ti =
typeid(T);
222 const std::type_info & ti =
typeid(T);
279 const std::string & prefix_ =
"")
const;
290 virtual void reset() = 0;
299 virtual void tree_dump(std::ostream & a_out = std::clog,
300 const std::string & a_title =
"",
301 const std::string & a_indent =
"",
302 bool a_inherit =
false)
const;
305 void print(std::ostream & a_out = std::clog)
const;
340 void _set_user_data(
const boost::shared_ptr<i_referenced_data> & hd_);
352 void _set_name(
const std::string & a_name);
393 bool _activated_counters_;
394 boost::shared_ptr<i_referenced_data> _user_data_;
395 size_t _number_of_accepted_entries_;
396 size_t _number_of_rejected_entries_;
411 #define CUT_REGISTRATION_INTERFACE(T) \ 413 virtual std::string get_type_id() const; \ 415 DATATOOLS_FACTORY_SYSTEM_AUTO_REGISTRATION_INTERFACE(::cuts::i_cut, T) \ 419 #define CUT_REGISTRATION_IMPLEMENT(T,CutID) \ 420 std::string T::get_type_id() const { return CutID; } \ 421 DATATOOLS_FACTORY_SYSTEM_AUTO_REGISTRATION_IMPLEMENTATION(::cuts::i_cut, T, CutID) \ 424 #endif // CUTS_I_CUT_H datatools::logger::priority _logging
Logging priority threshold.
Definition: i_cut.h:381
void _import_user_data_from(const i_cut &)
Import user data from another cut.
virtual ~referenced_data()
Definition: i_cut.h:109
referenced_data(const T &obj)
Definition: i_cut.h:106
virtual bool match(const std::type_info *tit_) const =0
void register_supported_user_data_type()
Register user data type is supported.
Definition: i_cut.h:195
void unregister_supported_user_data_type()
Unregister user data type is supported.
Definition: i_cut.h:205
export_config_flags
Flags for export to a container of properties.
Definition: i_cut.h:264
bool is_activated_counters() const
Check the flag to activate counters.
An abstract class for daughter templatized data wrapper classes.
Definition: i_cut.h:67
void reset_user_data()
Clear the referenced user data.
bool has_version() const
Check if the version of the cut is set.
void set_version(const std::string &a_version)
Return the version of the cut.
virtual void reset()=0
The main termination method.
void set_description(const std::string &a_description)
Set the description of the cut.
const T * _address
Address of the referenced object.
Definition: i_cut.h:114
The cut abstract base class (interface)
Definition: i_cut.h:62
void _set_initialized(bool a_initialized)
Set the initialization flag.
std::string _name
The name of the cut.
Definition: i_cut.h:382
const std::string & get_version() const
Return the version of the cut.
const T & get_user_data() const
Get user data of given type.
Definition: i_cut.h:181
void _export_user_data_to(i_cut &) const
Export user data to another cut.
const std::type_info * _ti
Definition: i_cut.h:115
virtual void tree_dump(std::ostream &a_out=std::clog, const std::string &a_title="", const std::string &a_indent="", bool a_inherit=false) const
Smart print.
virtual std::string get_type_id() const =0
Return the unique type identifier associated to the class of the cut object.
void _set_user_data(const boost::shared_ptr< i_referenced_data > &hd_)
Set user data by shared pointer.
Top-level namespace of the Bayeux/cuts module library.
Definition: accept_cut.h:21
virtual void _at_reset_user_data()
Hook executed when user data is reset.
void _set_defaults()
Set default attributes values.
#define DT_LOG_DEBUG(Priority, Message)
Log Message if Priority is greater or equal to PRIO_DEBUG.
Definition: logger_macros.h:147
const std::string & get_description() const
Return the description of the cut.
virtual void _prepare_cut()
Hook invoked before the main selection method.
size_t get_number_of_accepted_entries() const
Return the number of entries accepted by the cut.
void set_activated_counters(bool)
Set the flag to activate statistics.
virtual void _increment_counters(int a_selection_status)
Increment statistics counters.
size_t get_number_of_processed_entries() const
Return the total number of entries processed by the cut.
std::string _version
The version of the cut.
Definition: i_cut.h:384
virtual int _finish_cut(int a_selection_status)
Hook invoked after the main selection method.
bool is_initialized() const
Check initialization status.
void reset_counters()
Reset the embedded counters.
virtual ~i_referenced_data()
Definition: i_cut.h:71
virtual ~i_cut()
Destructor.
void _reset()
Reset the cut.
virtual const std::type_info * get_typeinfo() const =0
virtual const std::type_info * get_typeinfo() const
Definition: i_cut.h:85
int operator()()
Function interface for the selection method.
void _common_initialize(const datatools::properties &a_config)
Common initialization of all cuts.
std::string _description
The description of the cut.
Definition: i_cut.h:383
bool has_user_data() const
Check if some user data is referenced.
virtual void initialize_without_service(const datatools::properties &a_config, cut_handle_dict_type &a_cut_dictionary)
referenced_data()
Definition: i_cut.h:102
#define DT_THROW_IF(Condition, ExceptionType, Message)
Definition: exception.h:76
bool is_user_data() const
Check user data type.
Definition: i_cut.h:170
virtual void initialize_with_service_only(const datatools::properties &a_config, datatools::service_manager &a_service_manager)
void set_name(const std::string &a_name)
Set the name of the cut.
bool is_debug() const
Check if logging priority is at least at debug level.
A weak reference to an arbitrary object with tracked type_info
Definition: i_cut.h:76
void set_logging_priority(datatools::logger::priority p)
Set the logging priority threshold.
void set_user_data(const T &obj_)
Set user data.
Definition: i_cut.h:156
#define DT_LOG_TRACE(Priority, Message)
Log Message if Priority is greater or equal to PRIO_TRACE.
Definition: logger_macros.h:227
void _set_name(const std::string &a_name)
Set the cut name.
Utilities for logging information.
void reset()
Definition: i_cut.h:98
virtual void initialize(const datatools::properties &a_config, datatools::service_manager &a_service_manager, cut_handle_dict_type &a_cut_dictionary)=0
std::map< std::string, cut_entry_type > cut_handle_dict_type
Alias type of a dictionary of cut entry.
Definition: cut_tools.h:175
static void common_ocd(datatools::object_configuration_description &ocd_)
Basic OCD support shared by all inherited modules.
void set(const T &obj)
Definition: i_cut.h:91
bool is_user_data_type_supported() const
Check if data type is supported.
Definition: i_cut.h:215
const T & get() const
Definition: i_cut.h:78
bool has_description() const
Check if the description of the cut is set.
datatools::logger::priority get_logging_priority() const
Get the logging priority threshold.
virtual void initialize_standalone(const datatools::properties &a_config)
Initialization method through a container of configuration properties (default implementation,...
#define DATATOOLS_FACTORY_SYSTEM_REGISTER_INTERFACE(BaseType)
Declaration of a system (allocator/functor) factory register as a static member of a base class and s...
Definition: factory_macros.h:52
size_t get_number_of_rejected_entries() const
Return the number of entries rejected by the cut.
virtual void export_to_config(datatools::properties &config_, uint32_t flags_=EXPORT_CONFIG_DEFAULT, const std::string &prefix_="") const
Export to a container of properties.
void print(std::ostream &a_out=std::clog) const
Print shortcut.
virtual void initialize_simple()
Naked initialization method (default implementation,.
const std::string & get_name() const
Return the name of the cut.
bool has_name() const
Check if the name of the cut is set.
i_cut(datatools::logger::priority p=datatools::logger::PRIO_FATAL)
Constructor.
std::set< const std::type_info * > _supported_types_
The set of supported user data types.
Definition: i_cut.h:385
virtual bool match(const std::type_info *tit_) const
Definition: i_cut.h:88
virtual int _accept()=0
The main selection method (pure virtual, invoked by the.
virtual void _at_set_user_data()
Hook executed when user data is set.