Changeset 266 for trunk/src


Ignore:
Timestamp:
06/19/14 03:49:49 (11 years ago)
Author:
epyon
Message:
  • decoupling - uid_store independent of nv::object
  • decoupling - nv::object no longer linked with lua in any way
  • decoupling - gui::element related object methods moved to element
  • uid_store can operate on void* or specialized base class
  • root class no longer carries uid store nor lua state (will be removed later)
Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gui/gui_element.cc

    r257 r266  
    8181}
    8282
     83
     84bool element::move_to_top( element* child )
     85{
     86        list::iterator it = std::find( m_children.begin(), m_children.end(), (object*)child );
     87        if ( it != m_children.end() )
     88        {
     89                m_children.erase( it );
     90                m_children.push_back( child );
     91                return true;
     92        }       
     93        return false;
     94}
     95
     96bool element::move_to_bottom( element* child )
     97{
     98        list::iterator it = std::find( m_children.begin(), m_children.end(), (object*)child );
     99        if ( it != m_children.end() )
     100        {
     101                m_children.erase( it );
     102                m_children.push_front( child );
     103                return true;
     104        }       
     105        return false;
     106}
     107
    83108element::~element()
    84109{
  • trunk/src/object.cc

    r265 r266  
    88
    99#include <algorithm>
    10 #include "nv/types.hh"
    11 #include "nv/lua/lua_state.hh"
    12 #include "nv/uid.hh"
    1310
    1411using namespace nv;
     
    1815        , m_name()
    1916        , m_uid(0)
    20         , m_lua_index(lua::ref::none)
    21         , m_lua_proto_index(lua::ref::none)
    2217        , m_parent( nullptr )
    2318        , m_children()
     
    124119}
    125120
    126 bool object::move_to_top( object* child )
    127 {
    128         list::iterator it = std::find( m_children.begin(), m_children.end(), child );
    129         if ( it != m_children.end() )
    130         {
    131                 m_children.erase( it );
    132                 m_children.push_back( child );
    133                 return true;
    134         }       
    135         return false;
    136 }
    137 
    138 bool object::move_to_bottom( object* child )
    139 {
    140         list::iterator it = std::find( m_children.begin(), m_children.end(), child );
    141         if ( it != m_children.end() )
    142         {
    143                 m_children.erase( it );
    144                 m_children.push_front( child );
    145                 return true;
    146         }       
    147         return false;
    148 }
    149121
    150122// void object::register_type( type_database* db )
  • trunk/src/root.cc

    r265 r266  
    1010#include "nv/lua/lua_state.hh"
    1111
    12 void nv::root::object_created( object* o )
    13 {
    14         if ( m_uid_store )
    15         {
    16                 o->m_uid = m_uid_store->insert( o );
    17         }
    18 }
    19 
    2012void nv::root::destroy_object( object* o )
    2113{
    2214        destroy_children( o );
    2315        o->detach();
    24         if ( m_lua_state && o->m_lua_index != lua::ref::none )
    25         {
    26                 m_lua_state->unregister_object( lua::ref( o->m_lua_index ) );
    27         }
    28         if ( m_uid_store && o->m_uid != 0 )
    29         {
    30                 m_uid_store->remove( o->m_uid );
    31         }
    3216        delete o;
    3317}
     
    4024        }
    4125}
    42 
    43 void nv::root::register_with_lua( object* o, const char* lua_name, const char* storage )
    44 {
    45         if ( m_lua_state )
    46         {
    47                 if ( lua_name != nullptr )
    48                 {
    49                         o->m_lua_index       = m_lua_state->register_object( o, lua_name ).get();
    50                 }
    51                 if ( storage != nullptr )
    52                 {
    53                         o->m_lua_proto_index = m_lua_state->register_proto( o->get_id().c_str(), storage ).get();
    54                 }
    55         }
    56 
    57 }
    58 
  • trunk/src/uid.cc

    r59 r266  
    99using namespace nv;
    1010
    11 uid_store::uid_store()
     11uid_store_raw::uid_store_raw()
    1212        : m_map(), m_current(0)
    1313{
     
    1515}
    1616
    17 object* uid_store::get( uid auid ) const
     17void* uid_store_raw::get( uid auid ) const
    1818{
    1919        map::const_iterator i = m_map.find( auid );
     
    2525}
    2626
    27 bool uid_store::remove( uid auid )
     27bool uid_store_raw::remove( uid auid )
    2828{
    2929        return m_map.erase( auid ) != 0;
    3030}
    3131
    32 void uid_store::insert( object* o, uid auid )
     32void uid_store_raw::insert( void* o, uid auid )
    3333{
    3434        m_map[ auid ] = o;
    3535}
    3636
    37 uid uid_store::insert( object* o )
     37uid uid_store_raw::insert( void* o )
    3838{
    3939        uid u = request_uid();
     
    4242}
    4343
    44 uid uid_store::request_uid()
     44uid uid_store_raw::request_uid()
    4545{
    4646        return ++m_current;
    4747}
    4848
    49 uid_store::~uid_store()
     49uid_store_raw::~uid_store_raw()
    5050{
    5151        // no-op
Note: See TracChangeset for help on using the changeset viewer.