Visualization Library 2.0.0-b3

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
VLXRegistry.hpp
Go to the documentation of this file.
1 /**************************************************************************************/
2 /* */
3 /* Visualization Library */
4 /* http://visualizationlibrary.org */
5 /* */
6 /* Copyright (c) 2005-2017, Michele Bosi */
7 /* All rights reserved. */
8 /* */
9 /* Redistribution and use in source and binary forms, with or without modification, */
10 /* are permitted provided that the following conditions are met: */
11 /* */
12 /* - Redistributions of source code must retain the above copyright notice, this */
13 /* list of conditions and the following disclaimer. */
14 /* */
15 /* - Redistributions in binary form must reproduce the above copyright notice, this */
16 /* list of conditions and the following disclaimer in the documentation and/or */
17 /* other materials provided with the distribution. */
18 /* */
19 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND */
20 /* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */
21 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
22 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR */
23 /* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
24 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
25 /* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */
26 /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
27 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
28 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
29 /* */
30 /**************************************************************************************/
31 
32 #ifndef VLXRegistry_INCLUDE_ONCE
33 #define VLXRegistry_INCLUDE_ONCE
34 
36 #include <string>
37 #include <map>
38 
39 namespace vl
40 {
42  class VLXRegistry: public Object
43  {
45 
46  public:
47  void registerClassWrapper(const TypeInfo& type, VLXClassWrapper* wrapper)
48  {
49  std::string tag = std::string("<") + type.name() + ">";
50  mExportRegistry[type] = wrapper;
51  mImportRegistry[tag] = wrapper;
52  }
53 
54  std::map< std::string, ref<VLXClassWrapper> >& importRegistry() { return mImportRegistry; }
55  std::map< TypeInfo, ref<VLXClassWrapper> >& exportRegistry() { return mExportRegistry; }
56 
57  const std::map< std::string, ref<VLXClassWrapper> >& importRegistry() const { return mImportRegistry; }
58  const std::map< TypeInfo, ref<VLXClassWrapper> >& exportRegistry() const { return mExportRegistry; }
59 
60  private:
61  std::map< std::string, ref<VLXClassWrapper> > mImportRegistry; // <tag> --> VLXClassWrapper
62  std::map< TypeInfo, ref<VLXClassWrapper> > mExportRegistry; // TypeInfo --> VLXClassWrapper
63  };
64 
67 }
68 
69 #endif
VLCORE_EXPORT VLXRegistry * defVLXRegistry()
Definition: init_core.cpp:168
const std::map< TypeInfo, ref< VLXClassWrapper > > & exportRegistry() const
Definition: VLXRegistry.hpp:58
const std::map< std::string, ref< VLXClassWrapper > > & importRegistry() const
Definition: VLXRegistry.hpp:57
VLCORE_EXPORT void setDefVLXRegistry(VLXRegistry *reg)
Definition: init_core.cpp:172
std::map< std::string, ref< VLXClassWrapper > > & importRegistry()
Definition: VLXRegistry.hpp:54
#define VL_INSTRUMENT_CLASS(ClassName, BaseClass)
Definition: TypeInfo.hpp:122
void registerClassWrapper(const TypeInfo &type, VLXClassWrapper *wrapper)
Definition: VLXRegistry.hpp:47
Visualization Library main namespace.
Represents a class type.
Definition: TypeInfo.hpp:46
The base class for all the reference counted objects.
Definition: Object.hpp:158
std::map< TypeInfo, ref< VLXClassWrapper > > & exportRegistry()
Definition: VLXRegistry.hpp:55
Base cass for all class wrappers implementing the translation to/from its VLX representation.
Registry of vl::VLXClassWrapper objects, used by vl::VLXSerializer, see also vl::defVLXRegistry().
Definition: VLXRegistry.hpp:42
const char * name() const
The name of the class including the namespace.
Definition: TypeInfo.hpp:65