ScummVM API documentation
resourcereference.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef STARK_RESOURCES_RESOURCE_REFERENCE_H
23 #define STARK_RESOURCES_RESOURCE_REFERENCE_H
24 
25 #include "common/array.h"
26 #include "common/stream.h"
27 
28 #include "engines/stark/resources/object.h"
29 
30 namespace Stark {
31 
40 public:
42 
43  Common::String describe() const;
44 
46  void loadFromStream(Common::ReadStream *stream);
47 
49  void saveToStream(Common::WriteStream *stream);
50 
52  void buildFromResource(Resources::Object *resource);
53 
55  template <class T>
56  T* resolve() const;
57 
59  bool empty() const;
60 
62  bool canResolve() const;
63 private:
64  void addPathElement(Resources::Type type, uint16 index);
65  Resources::Object *resolve() const;
66 
67  class PathElement {
68  public:
69  PathElement(Resources::Type type, uint16 index);
70  Common::String describe() const;
71 
72  Resources::Type getType() const { return _type; }
73  uint16 getIndex() const { return _index; }
74 
75  private:
76  Resources::Type _type;
77  uint16 _index;
78  };
79 
81 };
82 
83 template<class T>
85  return Resources::Object::cast<T>(resolve());
86 }
87 
88 } // End of namespace Stark
89 
90 #endif // STARK_RESOURCES_RESOURCE_REFERENCE_H
Definition: object.h:37
Definition: str.h:59
Definition: stream.h:77
T * resolve() const
Definition: resourcereference.h:84
void loadFromStream(Common::ReadStream *stream)
Definition: resourcereference.h:39
Definition: console.h:27
Definition: object.h:143
void buildFromResource(Resources::Object *resource)
void saveToStream(Common::WriteStream *stream)
Definition: stream.h:385