~ubuntu-branches/debian/experimental/openscenegraph/experimental

« back to all changes in this revision

Viewing changes to OpenSceneGraph/include/osgIntrospection/Reflection

  • Committer: Bazaar Package Importer
  • Author(s): Alberto Luaces
  • Date: 2011-01-29 11:36:29 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20110129113629-qisrm2kdqlurc7t3
Tags: 2.9.11-1
* Removed bug-555869-ftbfs_with_binutils_gold.dpatch since upstream has
  already taken care of the issue.
* Removed bug-528229.dpatch since the pkgconfig files are now also split
  in upstream.
* Removed explicit dependency on GLU.
* Upstream no longer includes osgIntrospection (Closes: #592420).
* Disabled zip plugin as its implementation stores an embedded copy of
  zlib.
* Enabled Qt support. Thanks James Goppert.
* Enabled SVG and PDF plugins. Thanks James Goppert.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 
2
 
 *
3
 
 * This library is open source and may be redistributed and/or modified under  
4
 
 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
5
 
 * (at your option) any later version.  The full license is in LICENSE file
6
 
 * included with this distribution, and on the openscenegraph.org website.
7
 
 * 
8
 
 * This library is distributed in the hope that it will be useful,
9
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
11
 
 * OpenSceneGraph Public License for more details.
12
 
*/
13
 
//osgIntrospection - Copyright (C) 2005 Marco Jez
14
 
 
15
 
#ifndef OSGINTROSPECTION_REFLECTION_
16
 
#define OSGINTROSPECTION_REFLECTION_
17
 
 
18
 
#include <osgIntrospection/Export>
19
 
#include <osgIntrospection/ExtendedTypeInfo>
20
 
 
21
 
#include <typeinfo>
22
 
#include <map>
23
 
#include <vector>
24
 
#include <list>
25
 
 
26
 
/// This macro emulates the behavior of the standard typeid operator,
27
 
/// returning the Type object associated to the type of the given
28
 
/// expression.
29
 
#define typeof(type)  osgIntrospection::Reflection::getType(extended_typeid< type >())
30
 
#define typeofvalue(val)  osgIntrospection::Reflection::getType(osgIntrospection::ExtendedTypeInfo(typeid(val), false, false))
31
 
 
32
 
namespace osgIntrospection
33
 
{
34
 
 
35
 
    class Type;
36
 
    struct Converter;
37
 
    
38
 
    typedef std::list<const Converter* > ConverterList;
39
 
 
40
 
    /// A map of types, indexed by their associated ExtendedTypeInfo
41
 
    /// structure.
42
 
    typedef std::map<ExtendedTypeInfo, Type*> TypeMap;
43
 
 
44
 
    enum CastType
45
 
    {
46
 
        STATIC_CAST,
47
 
        DYNAMIC_CAST,
48
 
        REINTERPRET_CAST,
49
 
        COMPOSITE_CAST
50
 
    };
51
 
 
52
 
    /// This class provides basic reflection services such as registration
53
 
    /// of new types and queries on the global type map.
54
 
    class OSGINTROSPECTION_EXPORT Reflection
55
 
    {
56
 
    public:
57
 
        /// Returns the Type object associated to the given
58
 
        /// ExtendedTypeInfo structure. If the type hasn't been created
59
 
        /// yet it is automatically created and added to the global type
60
 
        /// map.  Please note that such type will have the status of
61
 
        /// "declared", you still need to give details about it through
62
 
        /// a Reflector class before you can query it.
63
 
        static const Type& getType(const ExtendedTypeInfo &ti);
64
 
 
65
 
        /// Finds a Type object given its qualified name, which must
66
 
        /// be identical to the qualified name returned by that Type's
67
 
        /// getQualifiedName() method. If the type hasn't been created
68
 
        /// yet, an exception is thrown.
69
 
        static const Type& getType(const std::string& qname);
70
 
 
71
 
        /// Returns the global map of types.
72
 
        static const TypeMap& getTypes();
73
 
 
74
 
        /// Return the Type object associated to the C++ type 'void'.
75
 
        /// This is a shortcut for typeof(void), which may be slow if
76
 
        /// the type map is large.
77
 
        static const Type& type_void();
78
 
 
79
 
        static const Converter* getConverter(const Type& source, const Type& dest);
80
 
        static bool getConversionPath(const Type& source, const Type& dest, ConverterList& conv);
81
 
        
82
 
        // This function should be called (at least on windows platforms using Visual Studio 7.1 or 8 as compiler) to unregister 
83
 
        // all the known types before exiting your program: otherwise, you will get a lot of false positive memory leaks in debug builds.
84
 
        // It might also be used to dynamically reload the description of the known types (?)
85
 
        static void uninitialize();
86
 
        
87
 
    private:
88
 
        template<typename C> friend class Reflector;
89
 
        template<typename C> friend struct TypeNameAliasProxy;
90
 
        friend struct ConverterProxy;
91
 
 
92
 
        struct StaticData
93
 
        {
94
 
            TypeMap typemap;
95
 
            const Type* type_void;
96
 
            
97
 
            typedef std::map<const Type* , const Converter* > ConverterMap;
98
 
            typedef std::map<const Type* , ConverterMap> ConverterMapMap;
99
 
            ConverterMapMap convmap;
100
 
            
101
 
            ~StaticData();
102
 
        };
103
 
 
104
 
        static StaticData& getOrCreateStaticData();
105
 
        static Type* registerType(const ExtendedTypeInfo &ti);
106
 
        static Type* getOrRegisterType(const ExtendedTypeInfo &ti, bool replace_if_defined = false);
107
 
        static void registerConverter(const Type& source, const Type& dest, const Converter* cvt);
108
 
 
109
 
    private:
110
 
        static bool accum_conv_path(const Type& source, const Type& dest, ConverterList& conv, std::vector<const Type* > &chain, CastType castType);
111
 
        static StaticData* _static_data;
112
 
    };
113
 
 
114
 
}
115
 
 
116
 
#endif