Changeset 257 for trunk/src/object.cc
- Timestamp:
- 06/14/14 22:40:25 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/object.cc
r256 r257 8 8 9 9 #include <algorithm> 10 #include "nv/root.hh"11 10 #include "nv/types.hh" 12 11 #include "nv/lua/lua_state.hh" … … 15 14 using namespace nv; 16 15 17 object::object() 18 : m_root( nullptr ) 19 , m_id() 16 object::object( const string& aid ) 17 : m_id( aid ) 20 18 , m_name() 21 19 , m_uid(0) … … 26 24 , m_child_count(0) 27 25 { 28 }29 30 object::object( root* aroot, const string& aid )31 : m_root( aroot )32 , m_id( aid )33 , m_name()34 , m_uid(0)35 , m_lua_index(lua::ref_none)36 , m_lua_proto_index(lua::ref_none)37 , m_parent( nullptr )38 , m_children()39 , m_child_count(0)40 {41 if ( m_root )42 {43 m_root->object_created( this );44 }45 26 } 46 27 … … 56 37 m_children.push_back( child ); 57 38 m_child_count++; 58 m_root->child_added( child );59 39 } 60 40 } … … 71 51 (*it)->m_parent = nullptr; 72 52 m_children.erase(it); 73 m_root->child_removed( child );74 53 } 75 54 } … … 89 68 } 90 69 91 void object::destroy_children()92 {93 while ( !m_children.empty() )94 {95 delete m_children.front();96 }97 }98 99 70 object::~object() 100 71 { 101 if ( m_root )102 {103 m_root->object_destroyed( this );104 }105 detach();106 destroy_children();107 72 } 108 73 … … 195 160 // db->create_type<object>("object").fields(fields); 196 161 // } 197 198 void nv::object::register_with_lua( const char* lua_name, const char* storage )199 {200 lua::state* state = get_root()->get_lua_state();201 if (state)202 {203 if ( lua_name != nullptr )204 {205 m_lua_index = state->register_object( this, lua_name );206 }207 if ( storage != nullptr )208 {209 m_lua_proto_index = state->register_proto( this, storage );210 }211 }212 }
Note: See TracChangeset
for help on using the changeset viewer.