soma-io  5.1.2
datasourceinfoloader.h
Go to the documentation of this file.
1 /* This software and supporting documentation are distributed by
2  * Institut Federatif de Recherche 49
3  * CEA/NeuroSpin, Batiment 145,
4  * 91191 Gif-sur-Yvette cedex
5  * France
6  *
7  * This software is governed by the CeCILL-B license under
8  * French law and abiding by the rules of distribution of free software.
9  * You can use, modify and/or redistribute the software under the
10  * terms of the CeCILL-B license as circulated by CEA, CNRS
11  * and INRIA at the following URL "http://www.cecill.info".
12  *
13  * As a counterpart to the access to the source code and rights to copy,
14  * modify and redistribute granted by the license, users are provided only
15  * with a limited warranty and the software's author, the holder of the
16  * economic rights, and the successive licensors have only limited
17  * liability.
18  *
19  * In this respect, the user's attention is drawn to the risks associated
20  * with loading, using, modifying and/or developing or reproducing the
21  * software by the user in light of its specific status of free software,
22  * that may mean that it is complicated to manipulate, and that also
23  * therefore means that it is reserved for developers and experienced
24  * professionals having in-depth computer knowledge. Users are therefore
25  * encouraged to load and test the software's suitability as regards their
26  * requirements in conditions enabling the security of their systems and/or
27  * data to be ensured and, more generally, to use and operate it in the
28  * same conditions as regards security.
29  *
30  * The fact that you are presently reading this means that you have had
31  * knowledge of the CeCILL-B license and that you accept its terms.
32  */
33 
34 #ifndef SOMAIO_DATASOURCEINFO_DATASOURCEINFOLOADER_H
35 #define SOMAIO_DATASOURCEINFO_DATASOURCEINFOLOADER_H
36 //--- soma-io ----------------------------------------------------------------
38 #include <soma-io/io/formatdictionary.h> // IOObjectTypesDictionary
39 //--- cartobase --------------------------------------------------------------
40 #include <cartobase/object/syntax.h> // SyntaxSet
41 #include <cartobase/object/object.h> // usage of none()
42 //--- system -----------------------------------------------------------------
43 #include <vector>
44 #include <string>
45 //----------------------------------------------------------------------------
46 
47 namespace soma
48 {
49  class FormatChecker;
50  class DataSource;
51  class DataSourceInfo;
52 
108  {
109  public:
110  enum State { Unchecked, Ok, Error };
113 
118  static void registerFormat( const std::string & fmtid,
119  FormatChecker* format,
120  const std::vector<std::string> &
121  extensions );
124  static FormatChecker* formatInfo( const std::string & format );
125 
144  carto::Object options = carto::none(),
145  int passbegin = 1, int passend = 3 );
146 
147  State state() const;
148  std::string errorMessage() const;
150 
157  carto::Object base = carto::none(),
158  carto::Object options = carto::none() );
161 
163  static std::set<std::string> extensions( const std::string & format );
164 
166  static std::set<std::string> formats( const std::string & ext );
167 
169  static std::set<std::string> readFormats(const std::string & ext,
170  const std::string & data_type_name);
171 
173  static std::set<std::string> writeFormats(const std::string & ext,
174  const std::string & data_type_name);
175 
176  protected:
178  static std::set<std::string> formats(
179  const std::string & ext,
181  );
182 
183  struct Private;
184  Private *d;
185  };
186 
187 }
188 
189 #endif
Generic information retreiver / checker for all data sources and file formats.
static std::set< std::string > formats(const std::string &ext)
Formats matching a specified extension.
static carto::Object readMinf(DataSource &ds, carto::Object base=carto::none(), carto::Object options=carto::none())
Called inter alia by format-specific FormatChecker to complete header information.
static carto::SyntaxSet & minfSyntax()
Syntax for minf dictionaries.
static std::set< std::string > writeFormats(const std::string &ext, const std::string &data_type_name)
Available writing formats for an extension and a data type.
static std::set< std::string > extensions(const std::string &format)
Extensions matching a specified format.
static void registerFormat(const std::string &fmtid, FormatChecker *format, const std::vector< std::string > &extensions)
Registers a FormatChecker into the dictionary.
static std::set< std::string > formats(const std::string &ext, soma::IOObjectTypesDictionary::FormatInfo &format_info)
Available formats for an extension and a format info.
DataSourceInfo check(DataSourceInfo dsi, carto::Object options=carto::none(), int passbegin=1, int passend=3)
Finds the right format checker.
static std::set< std::string > readFormats(const std::string &ext, const std::string &data_type_name)
Available reading formats for an extension and a data type.
static FormatChecker * formatInfo(const std::string &format)
Returns the corresponding FormatChecker.
std::string errorMessage() const
Informative object used by IO system.
Abstraction layer for various data sources (file, buffer, socket...).
Definition: datasource.h:65
Format Checker.
Definition: formatchecker.h:56
std::set< std::string >(* FormatInfo)()
std::map< std::string, Syntax > SyntaxSet
Object none()
Definition: allocator.h:49