anatomist  5.1.2
3D neuroimaging data viewer
oReader.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 
35 #ifndef ANA_OBJECT_OREADER_H
36 #define ANA_OBJECT_OREADER_H
37 
39 #include <qobject.h>
40 
41 class AimsFinder;
42 
43 
44 namespace anatomist
45 {
46 
47  class AObject;
48 
49 
57  {
58  public:
59  typedef std::vector<std::pair<AObject*,bool> > PostRegisterList;
60  typedef std::list<AObject *> (*LoadFunction)( const std::string & filename,
61  PostRegisterList & subObjectsToRegister,
62  carto::Object options );
63 
65  {
66  public:
67  virtual ~LoadFunctionClass();
68  virtual std::list<AObject *> load( const std::string & filename,
69  PostRegisterList & subObjectsToRegister,
70  carto::Object options ) = 0;
71  };
72 
74  virtual ~ObjectReader();
75 
77  static ObjectReader* reader();
78 
81  static void registerLoader( const std::string & extension,
82  LoadFunction newFunc );
86  static void registerLoader( const std::string & extension,
87  LoadFunctionClass *newFunc );
88 
89  virtual std::list<AObject *> load( const std::string & filename,
90  PostRegisterList & subObjectsToRegister,
91  bool notifyFail = true,
92  carto::Object options = carto::none(),
93  void* clientid=0 ) const;
94  virtual bool reload( AObject* object, bool notifyFail = true,
95  bool onlyoutdated = false ) const;
96  virtual AObject* readAims( const std::string & filename,
97  PostRegisterList & subObjectsToRegister,
98  carto::Object options = carto::none() ) const;
99  static std::string allSupportedFileExtensions();
100  static std::string anatomistSupportedFileExtensions();
101  static std::string supportedFileExtensions( const std::string & objtype );
102  static std::string
103  supportedFileExtensions( const std::set<std::string> & objtypes );
104  static std::set<std::string>
105  supportedFileExtensionsSet( const std::string & objtype );
106  static std::set<std::string>
109  static void cleanup();
110 
111  protected:
112  std::list<AObject *> load_internal( const std::string & filename,
113  PostRegisterList & subObjectsToRegister,
114  carto::Object options ) const;
115 
116  private:
118  typedef std::multimap<std::string, carto::rc_ptr<LoadFunctionClass> >
119  _storagetype;
120  static std::list<AObject*> readMObject(
121  const std::string & filename,
122  std::vector<std::pair<AObject *, bool> > &, carto::Object options );
123  static _storagetype & _loaders();
124  };
125 
126 }
127 
128 
129 #endif
Base Anatomist object (abstract)
Definition: Object.h:96
virtual std::list< AObject * > load(const std::string &filename, PostRegisterList &subObjectsToRegister, carto::Object options)=0
Object reader.
Definition: oReader.h:57
static ObjectReader * reader()
singleton access
virtual AObject * readAims(const std::string &filename, PostRegisterList &subObjectsToRegister, carto::Object options=carto::none()) const
std::list< AObject * >(* LoadFunction)(const std::string &filename, PostRegisterList &subObjectsToRegister, carto::Object options)
Definition: oReader.h:60
static std::string anatomistSupportedFileExtensions()
static std::set< std::string > anatomistSupportedFileExtensionsSet()
std::list< AObject * > load_internal(const std::string &filename, PostRegisterList &subObjectsToRegister, carto::Object options) const
static std::string supportedFileExtensions(const std::string &objtype)
static std::string supportedFileExtensions(const std::set< std::string > &objtypes)
static void registerLoader(const std::string &extension, LoadFunction newFunc)
Register a new extension and a loader function.
static std::string allSupportedFileExtensions()
static std::set< std::string > supportedFileExtensionsSet(const std::string &objtype)
virtual std::list< AObject * > load(const std::string &filename, PostRegisterList &subObjectsToRegister, bool notifyFail=true, carto::Object options=carto::none(), void *clientid=0) const
static void cleanup()
unregister all loaders (called when exiting)
std::vector< std::pair< AObject *, bool > > PostRegisterList
Definition: oReader.h:59
virtual bool reload(AObject *object, bool notifyFail=true, bool onlyoutdated=false) const
static void registerLoader(const std::string &extension, LoadFunctionClass *newFunc)
same as the above function but takes a class loader instead.
Object none()