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

Last change on this file since 361 was 361, checked in by epyon, 10 years ago
  • more string_ref changes
File size: 1.6 KB
Line 
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"
8#include "nv/core/range.hh"
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;
16        int correct = 0;
17        lua::register_storage( m_lua, get_storage_name(), constructor_name );
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() );
32        uint32 count = table.get_unsigned( "__counter" );
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_std_string("id") ] = rid;
38        }
39}
40
41nv::resource_type_id nv::resource_system::register_resource_type( const string& /*name*/, resource_manager_base* /*manager*/ )
42{
43        return 0;
44}
45
46nv::resource_type_id nv::resource_system::get_resource_type_id( const string& /*name*/ ) const
47{
48        return 0;
49}
50
51void nv::resource_system::initialize( lua::state* /*a_lua_state*/ )
52{
53
54}
55
56nv::resource_system::~resource_system()
57{
58
59}
Note: See TracBrowser for help on using the repository browser.