Bayeux  3.4.1
Core Foundation library for SuperNEMO
enriched_base.h
Go to the documentation of this file.
1 /* Author(s): Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date: 2013-09-12
4  * Last modified: 2015-04-18
5  *
6  * License:
7  *
8  * Copyright (C) 2013-2015 Francois Mauger <mauger@lpccaen.in2p3.fr>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 3 of the License, or (at
13  * your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful, but
16  * WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor,
23  * Boston, MA 02110-1301, USA.
24  *
25  * Description:
26  *
27  * A base class for complex objects with several basic attributes.
28  *
29  */
30 
31 #ifndef DATATOOLS_ENRICHED_BASE_H
32 #define DATATOOLS_ENRICHED_BASE_H
33 
34 // Standard library:
35 #include <iostream>
36 // - Breaks with GCC4.9.2_2 in C++98 :
37 // #include <cstdint> // requires C++11
38 // Third party:
39 #include <boost/cstdint.hpp>
40 
41 // This project:
42 #include <datatools/bit_mask.h>
44 #include <datatools/i_tree_dump.h>
45 #include <datatools/logger.h>
46 #include <datatools/properties.h>
47 
48 namespace datatools {
49  class object_configuration_description;
50 
55  {
56 
57  public:
58 
60  static bool validate_name(const std::string & candidate_name_);
61 
63  virtual bool is_name_valid(const std::string & name_) const;
64 
66  enriched_base();
67 
69  enriched_base(const std::string & name_,
70  const std::string & display_name_ = "",
71  const std::string & terse_description_ = "",
73 
75  virtual ~enriched_base();
76 
78  bool has_name() const;
79 
81  void set_name(const std::string & name_);
82 
84  enriched_base & set_name_c(const std::string & name_);
85 
87  const std::string & get_name() const;
88 
90  void reset_name();
91 
93  bool has_display_name() const;
94 
96  void set_display_name(const std::string & display_name_);
97 
99  enriched_base & set_display_name_c(const std::string & display_name_);
100 
102  const std::string & get_display_name() const;
103 
105  bool has_terse_description() const;
106 
108  void set_terse_description(const std::string & terse_description_);
109 
111  enriched_base & set_terse_description_c(const std::string & terse_description_);
112 
114  const std::string & get_terse_description() const;
115 
117  bool has_auxiliaries() const;
118 
120  const datatools::properties & get_auxiliaries() const;
121 
124 
126  void reset_auxiliaries();
127 
129  bool is_debug() const;
130 
133 
136 
138  void set_logging(const std::string & label_);
139 
142 
145 
147  void clear();
148 
150  void reset();
151 
153  void print_tree(std::ostream & out_ = std::clog,
154  const boost::property_tree::ptree & options_ = empty_options()) const override;
155 
157  void tree_dump(std::ostream & out_ = std::clog,
158  const std::string & title_ = "",
159  const std::string & indent_ = "",
160  bool inherit_ = false) const override;
161 
163  void initialize(const datatools::properties & config_, bool clear_ = false);
164 
178  };
179 
182  uint32_t flags_ = EXPORT_CONFIG_DEFAULT,
183  const std::string & prefix_ = "") const;
184 
187 
188  private:
189 
190  std::string _name_;
191  std::string _display_name_;
192  std::string _terse_description_;
193  logger::priority _logging_priority_;
194  datatools::properties _auxiliaries_;
195 
198 
199 #ifndef Q_MOC_RUN
200  DR_CLASS_RTTI()
202 #endif // Q_MOC_RUN
203 
204  };
205 
206 } // end of namespace datatools
207 
208 #include <boost/serialization/export.hpp>
209 BOOST_CLASS_EXPORT_KEY2(datatools::enriched_base, "datatools::enriched_base")
210 
211 #ifndef Q_MOC_RUN
212 // Activate reflection layer for the 'datatools::enriched_base' class:
214 #endif // Q_MOC_RUN
215 
216 #endif // DATATOOLS_ENRICHED_BASE_H
217 
218 // Local Variables: --
219 // mode: c++ --
220 // c-file-style: "gnu" --
221 // tab-width: 2 --
222 // End: --
static const boost::property_tree::ptree & empty_options()
#define DR_CLASS_INIT(Introspectable)
Inform Camp that class Introspectable exists and trigger the automatic registration of dedicated refl...
Definition: reflection_interface.h:149
void set_name(const std::string &name_)
Set the name.
enriched_base & set_display_name_c(const std::string &display_name_)
Set the display name.
Base abstract class of all serializable (and possibly introspectable) classes.
Definition: i_serializable.h:51
priority
Priority levels for logging from most to least critical.
Definition: logger.h:82
void initialize(const datatools::properties &config_, bool clear_=false)
Initialization from a container of properties.
static void init_ocd(datatools::object_configuration_description &)
OCD support.
void reset_auxiliaries()
Remove all auxiliary properties.
bool has_name() const
Check if the name is not empty.
An interface with utilities for printable objects.
Definition: i_tree_dump.h:36
A fatal error. The application will most likely terminate. This is the highest priority.
Definition: logger.h:85
#define DATATOOLS_SERIALIZATION_DECLARATION_ADVANCED(ClassName)
Definition: i_serializable.h:371
static const uint32_t bit01
Definition: bit_mask.h:28
Definition: enriched_base.h:177
void reset_name()
Reset the name.
static const uint32_t bit03
Definition: bit_mask.h:30
enriched_base()
Default constructor.
static const uint32_t bit04
Definition: bit_mask.h:31
void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const override
Smart print.
An object that describes the way an object of a given class can be configured through properties.
Definition: object_configuration_description.h:234
const std::string & get_display_name() const
Return the display name.
void set_logging_priority(logger::priority lp_)
Set the logging priority threshold.
logger::priority get_logging_priority() const
Return the logging priority threshold.
static bool validate_name(const std::string &candidate_name_)
Validate a name.
const std::string & get_terse_description() const
Return the description.
bool is_debug() const
Check the debug status.
datatools::properties & grab_auxiliaries()
Return a reference to the mutable container of auxiliary properties.
void export_to_config(datatools::properties &config_, uint32_t flags_=EXPORT_CONFIG_DEFAULT, const std::string &prefix_="") const
Export to a container of properties.
enriched_base & set_name_c(const std::string &name_)
Set the name.
void print_tree(std::ostream &out_=std::clog, const boost::property_tree::ptree &options_=empty_options()) const override
Smart print.
static const uint32_t bit02
Definition: bit_mask.h:29
bool has_terse_description() const
Check if the description is empty.
static const uint32_t bit05
Definition: bit_mask.h:32
const datatools::properties & get_auxiliaries() const
Return a reference to the non mutable container of auxiliary properties.
bool has_display_name() const
Check if the display name is empty.
virtual bool is_name_valid(const std::string &name_) const
Check if a name is valid.
bool has_auxiliaries() const
Check if the container of auxiliary properties is empty.
void set_terse_description(const std::string &terse_description_)
Set the description.
Definition: enriched_base.h:167
void set_logging(const std::string &label_)
Set the logging priority threshold from a string.
virtual ~enriched_base()
Destructor.
The Bayeux/datatools library top-level namespace.
Definition: algo.h:13
Utilities for logging information.
const std::string & get_name() const
Return the name.
static logger::priority default_logging_priority()
Return the default logging priority threshold.
A base class with useful attributes usable in many contexts.
Definition: enriched_base.h:52
enriched_base & set_logging_priority_c(logger::priority lp_)
Set the logging priority threshold.
static const uint32_t bit00
Definition: bit_mask.h:27
void set_display_name(const std::string &display_name_)
Set the display name.
#define DR_CLASS_RTTI()
Declare Camp RTTI within class declaration.
Definition: reflection_interface.h:46
enriched_base & set_terse_description_c(const std::string &terse_description_)
Set the description.
export_config_flags
Flags for export to a container of properties.
Definition: enriched_base.h:166
Definition: enriched_base.h:168
A dictionary of arbitrary properties.
Definition: properties.h:125