Bayeux  3.4.1
Core Foundation library for SuperNEMO
urn_to_path.h
Go to the documentation of this file.
1 /* Author(s): Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date: 2017-03-10
4  * Last modified: 2017-03-10
5  *
6  * License:
7  *
8  * Copyright (C) 2017 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  * URN to path association record.
28  *
29  */
30 
31 #ifndef DATATOOLS_URN_TO_PATH_H
32 #define DATATOOLS_URN_TO_PATH_H
33 
34 // Standard Library:
35 #include <string>
36 #include <vector>
37 
38 // Datatools:
40 #include <datatools/i_tree_dump.h>
41 #include <datatools/properties.h>
42 
43 namespace datatools {
44 
64  {
65  public:
66 
68  urn_to_path();
69 
71  urn_to_path(const std::string & urn_,
72  const std::string & path_,
73  const std::string & category_ = "",
74  const std::string & mime_ = "");
75 
77  urn_to_path(const std::string & urn_,
78  const std::string & category_,
79  const std::string & mime_,
80  const std::vector<std::string> & paths_);
81 
83  virtual ~urn_to_path();
84 
86  bool is_valid() const;
87 
89  void reset();
90 
92  bool has_urn() const;
93 
95  void set_urn(const std::string &);
96 
98  const std::string & get_urn() const;
99 
101  bool has_single_path() const;
102 
104  bool has_path() const;
105 
107  bool has_path_by_value(const std::string &) const;
108 
110  void set_path(const std::string & path_);
111 
113  const std::string & get_path() const;
114 
116  std::size_t get_number_of_paths() const;
117 
119  const std::string & get_path_by_index(const std::size_t index_ = 0) const;
120 
122  void add_path(const std::string &, bool preprend_ = false);
123 
125  void clear_paths();
126 
128  bool has_category() const;
129 
131  void set_category(const std::string &);
132 
134  const std::string & get_category() const;
135 
137  void reset_category();
138 
140  bool has_mime() const;
141 
143  void set_mime(const std::string &);
144 
146  const std::string & get_mime() const;
147 
149  void reset_mime();
150 
152  virtual void tree_dump (std::ostream & out_ = std::clog,
153  const std::string & title_ = "",
154  const std::string & indent_ = "",
155  bool inherit_ = false) const;
156 
157  private:
158 
159  std::string _urn_;
160  std::string _category_;
161  std::string _mime_;
162  std::vector<std::string> _paths_;
163 
166 
167  };
168 
169 } // end of namespace datatools
170 
171 #endif // DATATOOLS_URN_TO_PATH_H
172 
173 // Local Variables: --
174 // mode: c++ --
175 // c-file-style: "gnu" --
176 // tab-width: 2 --
177 // End: --
const std::string & get_category() const
Return the category.
Base abstract class of all serializable (and possibly introspectable) classes.
Definition: i_serializable.h:51
void clear_paths()
Remove all registered paths.
bool has_path() const
Check is at least one path is set.
An interface with utilities for printable objects.
Definition: i_tree_dump.h:36
bool has_single_path() const
Check if one single path is set.
#define DATATOOLS_SERIALIZATION_DECLARATION_ADVANCED(ClassName)
Definition: i_serializable.h:371
bool has_mime() const
Check if the MIME type is set.
void set_mime(const std::string &)
Set the MIME type.
void reset_mime()
Reset the MIME type.
urn_to_path()
Default constructor.
void add_path(const std::string &, bool preprend_=false)
Add a path (postpend)
bool has_category() const
Check if the category is set.
void set_category(const std::string &)
Set the category.
void set_path(const std::string &path_)
Set a single path at first position.
void reset_category()
Reset the category.
virtual ~urn_to_path()
Destructor.
bool has_path_by_value(const std::string &) const
Check if a specific path is registered.
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Main interface method for smart dump.
const std::string & get_path() const
Return the path at first position.
const std::string & get_urn() const
Return the URN identifier.
bool has_urn() const
Check if URN identifier is set.
The Bayeux/datatools library top-level namespace.
Definition: algo.h:13
std::size_t get_number_of_paths() const
Return the number of regisgtered paths.
bool is_valid() const
Check validity.
const std::string & get_path_by_index(const std::size_t index_=0) const
Return the path registered at given position.
const std::string & get_mime() const
Return the MIME type.
void set_urn(const std::string &)
Set the URN identifier.
A class representing the association of an URN to some paths. A path maybe a filesystem path,...
Definition: urn_to_path.h:61