openModeller  Version 1.5.0
RasterFactory.hh
Go to the documentation of this file.
1 
29 #ifndef _RASTER_FACTORYHH_
30 #define _RASTER_FACTORYHH_
31 
36 
37 #ifdef TERRALIB_FOUND
39 #endif
40 
41 #include <string>
42 using std::string;
43 
44 #include <map>
45 using std::map;
46 
47 class MapFormat;
48 
50 
56 class dllexp RasterFactory
57 {
58 
59 private:
60 
61  // Function pointer to builder function.
62  typedef Raster* (*CreateRasterCallback)();
63 
64  // Map of Rasters and identifiers.
65  typedef std::map<string, CreateRasterCallback> DriversMap;
66 
67 public:
68 
72  static RasterFactory& instance();
73 
78  bool registerDriver( const string& driverId, CreateRasterCallback builder );
79 
81  bool unregisterDriver( const string& driverId );
82 
86  Raster* create( const string& source, int categ = 0 );
87 
91  #ifdef MPI_FOUND
92  Raster* create( const string& output_file_source, const string& source, const MapFormat& format );
93  #else
94  Raster* create( const string& source, const MapFormat& format );
95  #endif
96 
97 private:
98 
99  // Indicates if the factory was initiated (i.e., drivers were registered).
100  static bool _initiated;
101 
104 
105  // No constructor allowed (singleton pattern).
107 
109  RasterFactory( const RasterFactory& );
110 
112  RasterFactory& operator=( const RasterFactory& );
113 
116 };
117 
118 #endif
119 
std::map< string, CreateRasterCallback > DriversMap
A common interface to rasters.
Definition: Raster.hh:44
Build a Raster.
~RasterFactory()
No destructor allowed.
DriversMap _drivers
Map of Rasters and identifiers.
static bool _initiated