aimsdata  5.1.2
Neuroimaging data handling
aimsGraphW.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  * Region Of Interest
36  */
37 #ifndef AIMS_IO_AIMSGRAPHW_H
38 #define AIMS_IO_AIMSGRAPHW_H
39 
40 #include <aims/io/process.h>
42 
43 class Graph;
44 
45 namespace aims
46 {
47  struct AimsGraphWriter_Private;
48 
49  namespace internal
50  {
51  struct AimsGraphWriter_ElemStruct;
52  }
53 
54 
55  class AimsGraphWriter : public Process
56  {
57  public:
59  {
60  Keep,
62  Local
63  };
64 
65  struct Wrapper
66  {
67  friend class AimsGraphWriter;
68 
69  virtual ~Wrapper() {}
70  virtual void destroy() {}
71 
72  virtual std::string objectType() const = 0;
73  virtual std::string dataType() const = 0;
74 
75  private:
76  virtual int freeindex() const = 0;
77  virtual bool write( const AimsGraphWriter & ) const = 0;
78  };
79 
80  template<typename T> struct ObjectWrapper : public Wrapper
81  {
82  friend class AimsGraphWriter;
83 
84  ObjectWrapper( T* x ) : data( x ) {}
85  virtual ~ObjectWrapper() {}
86  virtual void destroy() { delete data; }
87 
88  virtual std::string objectType() const;
89  virtual std::string dataType() const;
90 
91  T *data;
92 
93  private:
94  virtual int freeindex() const;
95  virtual bool write( const AimsGraphWriter & ) const;
96  };
97 
98  struct ElementInfo
99  {
102  std::string attribute;
104  };
105 
106  template<typename T> friend struct ObjectWrapper;
107 
108  AimsGraphWriter( const std::string & filename );
109  virtual ~AimsGraphWriter();
110 
123  virtual void writeElements( Graph & g, SavingMode newmode = Keep,
124  SavingMode oldmode = Keep,
125  bool saveOnlyModified = false );
126 
127  template<class T>
128  static bool defaultTakeObject( Process &, const std::string &, Finder & );
129  template <typename T> static bool isEmpty( const T & obj );
130 
131  const ElementInfo & elementInfo() const { return( info ); }
132  ElementInfo & elementInfo() { return( info ); }
133 
134  private:
135  template<class T> bool write( const T & ) const;
136  void writeElement( carto::AttributedObject *ao,
137  internal::AimsGraphWriter_ElemStruct & es );
138 
139  mutable ElementInfo info;
140  mutable AimsGraphWriter_Private *d;
141  };
142 
143 }
144 
145 
146 #endif
const ElementInfo & elementInfo() const
Definition: aimsGraphW.h:131
virtual void writeElements(Graph &g, SavingMode newmode=Keep, SavingMode oldmode=Keep, bool saveOnlyModified=false)
Saves elements contained in the graph.
virtual ~AimsGraphWriter()
static bool defaultTakeObject(Process &, const std::string &, Finder &)
Definition: aimsGraphW_d.h:200
static bool isEmpty(const T &obj)
Definition: aimsGraphW_d.h:127
AimsGraphWriter(const std::string &filename)
ElementInfo & elementInfo()
Definition: aimsGraphW.h:132
Generic finder / checker for all data objects and file formats This will replace the old AimsFinder.
Definition: finder.h:118
Link mechanism between the Finder and a process operating on arbitrary data types.
Definition: process.h:200
The class for EcatSino data write operation.
Definition: borderfiller.h:13
bool write(const T &obj, const std::string &filename, carto::Object options=carto::none(), const std::string *format=0)
Finds the correct format and writes the object, global version.
Definition: writer.h:141
carto::AttributedObject * element
Definition: aimsGraphW.h:101
virtual std::string objectType() const
Definition: aimsGraphW_d.h:113
virtual std::string dataType() const
Definition: aimsGraphW_d.h:120
virtual std::string dataType() const =0
virtual std::string objectType() const =0