The Gnome Chemistry Utils  0.14.0
loader.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 /*
4  * Gnome Chemistry Utils
5  * gcu/loader.h
6  *
7  * Copyright (C) 2007-2011 Jean Bréfort <jean.brefort@normalesup.org>
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 3 of the
12  * License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
22  * USA
23  */
24 
25 #ifndef GCU_LOADER_H
26 #define GCU_LOADER_H
27 
28 #include "structs.h"
29 #include <list>
30 #include <map>
31 #include <string>
32 #include <goffice/goffice.h>
33 #include <gsf/gsf-input.h>
34 #include <gsf/gsf-output.h>
35 
37 namespace gcu {
38 
39 class Document;
40 class Loader;
41 class Object;
42 
48 typedef struct {
56  bool read;
60  bool write;
64  bool supports2D;
68  bool supports3D;
77 } LoaderStruct;
78 
144 class Loader
145 {
146 public:
151  Loader ();
156  virtual ~Loader ();
157 
158  // static methods
165  static void Init (Application *app);
174  static bool GetFirstLoader (std::map<std::string, LoaderStruct>::iterator &it);
181  static bool GetNextLoader (std::map<std::string, LoaderStruct>::iterator &it);
186  static Loader *GetLoader (char const *mime_type);
191  static Loader *GetSaver (char const *mime_type);
192 
193  // virtual methods
205  virtual ContentType Read (Document *doc, GsfInput *in, char const *mime_type, GOIOContext *io);
218  virtual bool Write (Object const *obj, GsfOutput *out, char const *mime_type, GOIOContext *io, ContentType type = ContentTypeMisc);
219 
220 protected:
226  void AddMimeType (const char *mime_type);
232  void RemoveMimeType (const char *mime_type);
233 
234 private:
235  static bool Inited;
236 
237 protected:
241  std::list<std::string> MimeTypes;
242 };
243 
244 }
245 
246 #endif // GCU_LOADER_H