1 /**
2  *   SFCGAL
3  *
4  *   Copyright (C) 2012-2013 Oslandia <infos@oslandia.com>
5  *   Copyright (C) 2012-2013 IGN (http://www.ign.fr)
6  *
7  *   This library is free software; you can redistribute it and/or
8  *   modify it under the terms of the GNU Library General Public
9  *   License as published by the Free Software Foundation; either
10  *   version 2 of the License, or (at your option) any later version.
11  *
12  *   This library is distributed in the hope that it will be useful,
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  *   Library General Public License for more details.
16 
17  *   You should have received a copy of the GNU Library General Public
18  *   License along with this library; if not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef _SFCGAL_REGISTRY_H_
22 #define _SFCGAL_REGISTRY_H_
23 
24 #include <SFCGAL/config.h>
25 
26 #include <string>
27 #include <map>
28 #include <vector>
29 
30 namespace SFCGAL {
31 class Geometry ;
32 }
33 
34 namespace SFCGAL {
35 namespace tools {
36 
37 /**
38  * Registry for dynamic information about SFCGAL library
39  */
40 class SFCGAL_API Registry {
41 public:
42     typedef std::vector< Geometry* >::iterator       prototype_iterator ;
43     typedef std::vector< Geometry* >::const_iterator const_prototype_iterator ;
44 
45     /**
46      * destructor
47      */
48     ~Registry();
49 
50     /**
51      * Register a new Geometry type
52      */
53     void addPrototype( const Geometry& g ) ;
54 
55     /**
56      * returns the list of the geometry types
57      */
58     std::vector< std::string > getGeometryTypes() const ;
59 
60     /**
61      * returns a new instance of the given geometryTypeName
62      */
63     Geometry*  newGeometryByTypeName( const std::string& geometryTypeName ) const ;
64 
65     /**
66      * returns a new instance of the given geometryType
67      */
68     Geometry*  newGeometryByTypeId( int typeId ) const ;
69 
70     /**
71      * returns the instance of the registry
72      */
73     static Registry& instance() ;
74 private:
75     /**
76      * static instance of the Singleton
77      */
78     static Registry* _instance ;
79     /**
80      * prototypes of the geometries
81      */
82     std::vector< Geometry* > _prototypes ;
83 
84     /**
85      * init registry
86      */
87     Registry() ;
88 };
89 
90 }//namespace tools
91 }//namespace SFCGAL
92 
93 #endif
94