A.I.M.S


aimsGraphR.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 AIMS_IO_AIMSGRAPHR_H
35 #define AIMS_IO_AIMSGRAPHR_H
36 
37 #include <aims/io/process.h>
38 #include <aims/bucket/bucket.h>
40 #include <set>
41 
42 class Graph;
43 
44 namespace aims
45 {
46 
47  namespace internal
48  {
49  struct AimsGraphReader_Private;
50  struct AimsGraphReader_ElemStruct;
51  }
52 
58  class AimsGraphReader : public Process
59  {
60  public:
62 
63  struct Wrapper
64  {
65  friend class AimsGraphReader;
66 
67  virtual ~Wrapper() {}
68  virtual void destroy() {}
69 
70  virtual std::string objectType() const = 0;
71  virtual std::string dataType() const = 0;
72 
73  private:
74  virtual Wrapper *extract( int index ) = 0;
75  };
76 
77  template<typename T> struct ObjectWrapper : public Wrapper
78  {
79  ObjectWrapper( T* x ) : data( x ) {}
80  virtual ~ObjectWrapper() {}
81  virtual void destroy() { delete data; }
82 
83  virtual std::string objectType() const;
84  virtual std::string dataType() const;
85 
86  T *data;
87 
88  private:
89  virtual Wrapper *extract( int index );
90  };
91 
92  struct ElementInfo
93  {
96  std::string attribute;
98  };
99 
100  class PostProcessor : public Process
101  {
102  public:
103  friend class AimsGraphReader;
104  PostProcessor();
105  virtual ~PostProcessor();
106  const ElementInfo & elementInfo() const { return( info ); }
107  ElementInfo & elementInfo() { return( info ); }
108 
109  private:
110  ElementInfo info;
111  };
112 
113  AimsGraphReader( const std::string & filename );
114  virtual ~AimsGraphReader();
115 
148  virtual void readElements( Graph & g, int mask = 1 );
160  void setReadFilter( const std::set<std::string> & toread );
166  void setExcludeFilter( const std::set<std::string> & toexclude );
182  void setInsertionFunction( const std::string & objType,
183  const std::string & dataType,
184  ProcFunc procFunc );
196  template<class T> static
197  bool read( Process &, const std::string &, Finder & );
198 
200  static void loadAllMissingElements( Graph & );
201 
202  private:
203  template<class T> static
204  bool defaultInsertFunction( Process &, const std::string &, Finder & );
205  virtual void readElement( carto::AttributedObject* ao,
206  internal::AimsGraphReader_ElemStruct & es );
207 
209  };
210 
211 }
212 
213 
214 #endif
215 
AimsGraphReader(const std::string &filename)
BucketMap< Void > * mask(const BucketMap< Void > &src, const BucketMap< Void > &m, bool intersect=true)
mask src object with m.
void setExcludeFilter(const std::set< std::string > &toexclude)
Filters objects IDs in the graph file to be read as Aims objects.
virtual ~AimsGraphReader()
Reader / postprocessor for graph reading.
Definition: aimsGraphR.h:58
virtual std::string objectType() const =0
virtual std::string dataType() const =0
virtual std::string dataType() const
Definition: aimsGraphR_d.h:99
static bool read(Process &, const std::string &, Finder &)
Aims object reading function - called by the Process mechanism.
Definition: aimsGraphR_d.h:106
Generic finder / checker for all data objects and file formats This will replace the old AimsFinder...
Definition: finder.h:117
virtual void readElements(Graph &g, int mask=1)
Reads internal objects and stores them in the graph.
static void loadAllMissingElements(Graph &)
convenient function to load everything that can be loaded.
void setReadFilter(const std::set< std::string > &toread)
Filters objects IDs in the graph file to be read as Aims objects.
carto::AttributedObject * element
Definition: aimsGraphR.h:95
bool(* ProcFunc)(Process &, const std::string &, Finder &)
Process function type.
Definition: process.h:213
void setInsertionFunction(const std::string &objType, const std::string &dataType, ProcFunc procFunc)
Registers a post-processing function.
const ElementInfo & elementInfo() const
Definition: aimsGraphR.h:106
virtual std::string objectType() const
Definition: aimsGraphR_d.h:92
Link mechanism between the Finder and a process operating on arbitrary data types.
Definition: process.h:199