Bayeux  3.4.1
Core Foundation library for SuperNEMO
signal_data.h
Go to the documentation of this file.
1 /* Author(s) : Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date : 2016-09-28
4  * Last modified : 2016-09-28
5  *
6  * Copyright (C) 2016 Francois Mauger <mauger@lpccaen.in2p3.fr>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or (at
11  * your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  * Boston, MA 02110-1301, USA.
22  *
23  * Description:
24  *
25  * A container hosting collections of signal hits.
26  *
27  */
28 
29 #ifndef MCTOOLS_SIGNAL_SIGNAL_DATA_H
30 #define MCTOOLS_SIGNAL_SIGNAL_DATA_H
31 
32 // Standard Library:
33 #include <string>
34 #include <map>
35 #include <vector>
36 
37 // Third party:
38 // - Boost :
39 #include <boost/serialization/access.hpp>
40 #include <boost/cstdint.hpp>
41 // - Bayeux/datatools :
43 #include <datatools/i_tree_dump.h>
44 #include <datatools/handle.h>
45 #include <datatools/properties.h>
46 
47 // This project:
49 
50 namespace mctools {
51  namespace signal {
52 
54  class signal_data :
57  {
58  public:
59 
62  typedef std::vector<signal_handle_type> signal_handle_collection_type;
63  typedef std::map<std::string, signal_handle_collection_type> signals_dict_type;
64 
66  signal_data();
67 
69  virtual ~signal_data();
70 
72  const datatools::properties & get_auxiliaries() const;
73 
76 
79 
81  bool has_signals(const std::string & a_category) const;
82 
84  void add_signals(const std::string & a_category, size_t a_capacity = 0);
85 
87  size_t get_number_of_signals(const std::string & a_category) const;
88 
90  const base_signal & get_signal(const std::string & a_category, int a_hit_index) const;
91 
93  base_signal & grab_signal(const std::string & a_category, int a_hit_index);
94 
96  base_signal & add_signal(const std::string & a_category);
97 
99  void remove_signal(const std::string & a_category, int a_hit_index);
100 
103  grab_signals(const std::string & a_category);
104 
107  get_signals(const std::string & a_category) const;
108 
110  void remove_signals(const std::string & a_category);
111 
113  void build_list_of_categories(std::vector<std::string> & cats_) const;
114 
116  void clear();
117 
119  void reset();
120 
122  virtual void tree_dump(std::ostream & out_ = std::clog,
123  const std::string & title_ = "",
124  const std::string & indent_ = "",
125  bool inherit_ = false) const;
126 
127  private:
128 
129  datatools::properties _auxiliaries_;
130  signals_dict_type _signals_dict_;
131 
132  // datatools/Boost/brio serialization:
134 
135 #if MCTOOLS_WITH_REFLECTION == 1
136  DR_CLASS_RTTI()
138 #endif
139 
140  };
141 
142  } // end of namespace signal
143 } // end of namespace mctools
144 
145 #include <boost/serialization/export.hpp>
146 BOOST_CLASS_EXPORT_KEY2(mctools::signal::signal_data, "mctools::signal::signal_data")
147 
148 #if MCTOOLS_WITH_REFLECTION == 1
149 // Activate reflection support for the mctools::signal::signal_data class :
151 #endif // MCTOOLS_WITH_REFLECTION
152 
153 #endif // MCTOOLS_SIGNAL_SIGNAL_DATA_H
154 
155 // Local Variables: --
156 // mode: c++ --
157 // c-file-style: "gnu" --
158 // tab-width: 2 --
159 // End: --
#define DR_CLASS_INIT(Introspectable)
Inform Camp that class Introspectable exists and trigger the automatic registration of dedicated refl...
Definition: reflection_interface.h:149
Abstract base class representing an analog signal associated to a hit detector.
Definition: base_signal.h:55
void build_list_of_categories(std::vector< std::string > &cats_) const
Build list of signal categories.
signal_handle_collection_type & grab_signals(const std::string &a_category)
Return a reference to the mutable collection of signals within a given category.
Base abstract class of all serializable (and possibly introspectable) classes.
Definition: i_serializable.h:51
Definition: base_step_hit.h:32
virtual ~signal_data()
Destructor.
void add_signals(const std::string &a_category, size_t a_capacity=0)
Add a new collection of signal hits with some given category and a default capacity for memory alloca...
std::vector< signal_handle_type > signal_handle_collection_type
Definition: signal_data.h:62
const base_signal & get_signal(const std::string &a_category, int a_hit_index) const
Get a reference to the non mutable signal hit within a given category and index.
An interface with utilities for printable objects.
Definition: i_tree_dump.h:36
datatools::handle< base_signal > signal_handle_type
Alias for the MC base step hit.
Definition: signal_data.h:61
void set_auxiliaries(const datatools::properties &)
Set the collection of auxiliary properties.
#define DATATOOLS_SERIALIZATION_DECLARATION()
Definition: i_serializable.h:266
const datatools::properties & get_auxiliaries() const
Get a reference to the non mutable collection of auxiliary properties.
base_signal & add_signal(const std::string &a_category)
Add/append a new signal hit in a collection of signal hits with some given category.
size_t get_number_of_signals(const std::string &a_category) const
Get the number of signals hits within a given category.
Templatized handle class that wraps a Boost shared pointer and behaves like a reference.
Definition: handle.h:114
bool has_signals(const std::string &a_category) const
Check is some signals exist in some given category.
The container of collections of modelled analog signals.
Definition: signal_data.h:54
base_signal & grab_signal(const std::string &a_category, int a_hit_index)
Get a reference to the mutable signal hit within a given category and index.
std::map< std::string, signal_handle_collection_type > signals_dict_type
Definition: signal_data.h:63
signal_data()
Default constructor.
void clear()
Reset the internal data.
void remove_signal(const std::string &a_category, int a_hit_index)
remove a signal hit in a collection of signal hits with some given category and index
void remove_signals(const std::string &a_category)
Remoive the collection of signals within a given category.
#define DR_CLASS_RTTI()
Declare Camp RTTI within class declaration.
Definition: reflection_interface.h:46
datatools::properties & grab_auxiliaries()
Get a reference to the mutable collection of auxiliary properties.
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart print.
const signal_handle_collection_type & get_signals(const std::string &a_category) const
Return a reference to the non mutable collection of signals within a given category.
A dictionary of arbitrary properties.
Definition: properties.h:125