source: trunk/src/engine/resource_system.cc @ 358

Last change on this file since 358 was 358, checked in by epyon, 10 years ago
  • fixed string_ref constructor
  • implementing string_ref usage in lua: lua_nova string usage optimized lua_values string_ref entries
File size: 1.6 KB
RevLine 
[316]1// Copyright (C) 2014 ChaosForge Ltd
2// http://chaosforge.org/
3//
4// This file is part of NV Libraries.
5// For conditions of distribution and use, see copyright notice in nv.hh
6
7#include "nv/engine/resource_system.hh"
[319]8#include "nv/core/range.hh"
[316]9#include "nv/lua/lua_nova.hh"
10
11void nv::resource_manager_base::initialize( lua::state* a_lua_state )
12{
13        m_lua = a_lua_state;
14        std::string constructor_name( get_resource_name() );
15        constructor_name = "register_"+constructor_name;
[358]16        int correct = 0;
17        lua::register_storage( m_lua, get_storage_name(), constructor_name );
[316]18}
19
20nv::resource_id nv::resource_manager_base::load_resource( const std::string& id )
21{
22        lua::table_guard table( m_lua, lua::path( get_storage_name(), id ) );
23        resource_id rid = load_resource( table );
24        if ( rid != 0 ) m_names[ id ] = rid;
25        return rid;
26}
27
28void nv::resource_manager_base::load_all()
29{
30        clear();
31        lua::table_guard table( m_lua, get_storage_name() );
[323]32        uint32 count = table.get_unsigned( "__counter" );
[316]33        for ( auto i : range( count ) )
34        {
35                lua::table_guard sub_table( table, i+1 );
36                resource_id rid = load_resource( sub_table );
37                if ( rid != 0 ) m_names[ sub_table.get_string("id") ] = rid;
38        }
39}
40
[319]41nv::resource_type_id nv::resource_system::register_resource_type( const string& /*name*/, resource_manager_base* /*manager*/ )
[316]42{
43        return 0;
44}
45
[319]46nv::resource_type_id nv::resource_system::get_resource_type_id( const string& /*name*/ ) const
[316]47{
48        return 0;
49}
50
[319]51void nv::resource_system::initialize( lua::state* /*a_lua_state*/ )
[316]52{
53
54}
55
56nv::resource_system::~resource_system()
57{
58
59}
Note: See TracBrowser for help on using the repository browser.