Test object identity with shared_ptr_converter.
[luabind.git] / luabind / detail / class_registry.hpp
blob4d7740d568952e03e7561020178b572f4d334545
1 // Copyright (c) 2003 Daniel Wallin and Arvid Norberg
3 // Permission is hereby granted, free of charge, to any person obtaining a
4 // copy of this software and associated documentation files (the "Software"),
5 // to deal in the Software without restriction, including without limitation
6 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 // and/or sell copies of the Software, and to permit persons to whom the
8 // Software is furnished to do so, subject to the following conditions:
10 // The above copyright notice and this permission notice shall be included
11 // in all copies or substantial portions of the Software.
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
14 // ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
15 // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
16 // PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
17 // SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
18 // ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
21 // OR OTHER DEALINGS IN THE SOFTWARE.
24 #ifndef LUABIND_CLASS_REGISTRY_HPP_INCLUDED
25 #define LUABIND_CLASS_REGISTRY_HPP_INCLUDED
27 #include <map>
29 #include <luabind/config.hpp>
30 #include <luabind/open.hpp>
31 #include <luabind/typeid.hpp>
33 namespace luabind { namespace detail
35 class class_rep;
37 struct LUABIND_API class_registry
39 class_registry(lua_State* L);
41 static class_registry* get_registry(lua_State* L);
43 int cpp_instance() const { return m_instance_metatable; }
44 int cpp_class() const { return m_cpp_class_metatable; }
46 int lua_instance() const { return m_instance_metatable; }
47 int lua_class() const { return m_lua_class_metatable; }
48 int lua_function() const { return m_lua_function_metatable; }
50 void add_class(type_id const& info, class_rep* crep);
52 class_rep* find_class(type_id const& info) const;
54 private:
56 std::map<type_id, class_rep*> m_classes;
58 // this is a lua reference that points to the lua table
59 // that is to be used as meta table for all C++ class
60 // instances. It is a kind of v-table.
61 int m_instance_metatable;
63 // this is a lua reference to the metatable to be used
64 // for all classes defined in C++.
65 int m_cpp_class_metatable;
67 // this is a lua reference to the metatable to be used
68 // for all classes defined in lua
69 int m_lua_class_metatable;
71 // this metatable only contains a destructor
72 // for luabind::Detail::free_functions::function_rep
73 int m_lua_function_metatable;
79 #endif // LUABIND_CLASS_REGISTRY_HPP_INCLUDED