soma-io 6.0.6
formatdictionary.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_IO_FORMATDICTIONARY_H
35#define SOMAIO_IO_FORMATDICTIONARY_H
36//--- soma-io ----------------------------------------------------------------
38//--- cartobase --------------------------------------------------------------
39#include <cartobase/object/object.h>
40//--- system -----------------------------------------------------------------
41#include <string>
42#include <map>
43#include <set>
44#include <vector>
45//----------------------------------------------------------------------------
46
47namespace soma
48{
49 template <typename T> class FormatReader;
50 template <typename T> class FormatWriter;
51
74 template<typename T>
76 {
77 public:
78 static void registerFormat( const std::string & formatID,
79 FormatReader<T>* format,
80 const std::vector<std::string> & extensions );
81 static void registerFormat( const std::string & formatID,
82 FormatWriter<T>* format,
83 const std::vector<std::string> & extensions );
84 static FormatReader<T>* readFormat( const std::string & format );
85 static FormatWriter<T>* writeFormat( const std::string & format );
86 static const std::multimap<std::string, std::string> & readExtensions();
87 static const std::multimap<std::string, std::string> & writeExtensions();
88 static std::set<std::string> readFormats();
89 static std::set<std::string> writeFormats();
93 static void registerBaseFormats();
94 static void init();
95
96 private:
97 static std::map<std::string, FormatReader<T>*> & _readformats();
98 static std::map<std::string, FormatWriter<T>*> & _writeformats();
99 static std::multimap<std::string, std::string> & _readextensions();
100 static std::multimap<std::string, std::string> & _writeextensions();
101 };
102
103
106 {
107 public:
108 typedef std::set<std::string> (*FormatInfo)();
109 static void registerReadType( const std::string & datatype,
110 FormatInfo info );
111 static void registerWriteType( const std::string & datatype,
112 FormatInfo info );
113 static bool hasReadType( const std::string & datatype );
114 static bool hasWriteType( const std::string & datatype );
115 static std::map<std::string, FormatInfo> & readTypes();
116 static std::map<std::string, FormatInfo> & writeTypes();
117 };
118
119 extern template class FormatDictionary<carto::GenericObject>;
120 extern template class FormatDictionary<carto::Object>;
121}
122
123#endif
Formats holder for each format of Cartograph object, used by Reader and Writer.
static const std::multimap< std::string, std::string > & readExtensions()
static std::set< std::string > readFormats()
static const std::multimap< std::string, std::string > & writeExtensions()
static void registerFormat(const std::string &formatID, FormatReader< T > *format, const std::vector< std::string > &extensions)
static std::set< std::string > writeFormats()
static FormatWriter< T > * writeFormat(const std::string &format)
static void registerBaseFormats()
builds base formats maps.
static FormatReader< T > * readFormat(const std::string &format)
Low-level object IO reader specialized for a specific format.
Low-level object IO writer specialized for a specific format.
Global dictionary of supported object types for IO.
std::set< std::string >(* FormatInfo)()
static std::map< std::string, FormatInfo > & writeTypes()
static void registerWriteType(const std::string &datatype, FormatInfo info)
static bool hasReadType(const std::string &datatype)
static std::map< std::string, FormatInfo > & readTypes()
static void registerReadType(const std::string &datatype, FormatInfo info)
static bool hasWriteType(const std::string &datatype)