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

Last change on this file since 438 was 433, checked in by epyon, 10 years ago
  • string.hh split into separate files
  • string.hh - removed std::string conversions (header still stays though)
File size: 1.6 KB
Line 
1// Copyright (C) 2014-2015 ChaosForge Ltd
2// http://chaosforge.org/
3//
4// This file is part of Nova libraries.
5// For conditions of distribution and use, see copying.txt file in root folder.
6
7#include "nv/engine/resource_system.hh"
8#include "nv/stl/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 delete_me = "register_" + std::string( get_resource_name().data(), get_resource_name().size() );
15        lua::register_storage( m_lua, get_storage_name(), string_view( delete_me.c_str(), delete_me.size() ) );
16}
17
18nv::resource_id nv::resource_manager_base::load_resource( const string_view& id )
19{
20        lua::table_guard table( m_lua, lua::path( get_storage_name(), id ) );
21        resource_id rid = load_resource( table );
22        if ( rid != 0 ) m_names[ id ] = rid;
23        return rid;
24}
25
26void nv::resource_manager_base::load_all()
27{
28        clear();
29        lua::table_guard table( m_lua, get_storage_name() );
30        uint32 count = table.get_unsigned( "__counter" );
31        for ( auto i : range( count ) )
32        {
33                lua::table_guard sub_table( table, i+1 );
34                resource_id rid = load_resource( sub_table );
35                if ( rid != 0 ) m_names[ sub_table.get_string_hash_64("id") ] = rid;
36        }
37}
38
39nv::resource_type_id nv::resource_system::register_resource_type( const string_view& /*name*/, resource_manager_base* /*manager*/ )
40{
41        return 0;
42}
43
44nv::resource_type_id nv::resource_system::get_resource_type_id( const string_view& /*name*/ ) const
45{
46        return 0;
47}
48
49void nv::resource_system::initialize( lua::state* /*a_lua_state*/ )
50{
51
52}
53
54nv::resource_system::~resource_system()
55{
56
57}
Note: See TracBrowser for help on using the repository browser.