Simulant  21.12-194
A portable game engine for Windows, OSX, Linux, Dreamcast, and PSP
asset.h
1 /* * Copyright (c) 2011-2017 Luke Benstead https://simulant-engine.appspot.com
2  *
3  * This file is part of Simulant.
4  *
5  * Simulant is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * Simulant is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with Simulant. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #pragma once
20 
21 #include <cassert>
22 #include <string>
23 #include <chrono>
24 #include <memory>
25 
26 #include "generic/property.h"
27 #include "generic/data_carrier.h"
28 #include "generic/object_manager.h"
29 #include "interfaces/nameable.h"
30 #include "threads/mutex.h"
31 
32 namespace smlt {
33 
34 class AssetManager;
35 
36 class Asset:
37  public virtual Nameable {
38 
39 public:
40  friend class AssetManager;
41 
42  Asset(AssetManager* manager);
43 
44  virtual ~Asset();
45 
46  AssetManager& asset_manager() { assert(manager_); return *manager_; }
47  const AssetManager& asset_manager() const { assert(manager_); return *manager_; }
48 
49  int age() const;
50 
51  void set_garbage_collection_method(GarbageCollectMethod method);
52 
53  Property<generic::DataCarrier Asset::*> data = {this, &Asset::data_};
54 
55 protected:
56  Asset(const Asset& rhs);
57  Asset& operator=(const Asset& rhs);
58 private:
59  AssetManager* manager_;
60 
61  std::chrono::time_point<std::chrono::system_clock> created_;
62 
64 };
65 
66 }
67 
smlt::Property
Definition: property.h:202
smlt
Definition: animation.cpp:25
smlt::Asset
Definition: asset.h:37
smlt::generic::DataCarrier
Definition: data_carrier.h:37
smlt::AssetManager
Definition: asset_manager.h:100
smlt::Nameable
The Nameable class.
Definition: nameable.h:12