1 | // Aseprite Document Library |
2 | // Copyright (c) 2001-2015 David Capello |
3 | // |
4 | // This file is released under the terms of the MIT license. |
5 | // Read LICENSE.txt for more information. |
6 | |
7 | #ifndef DOC_SUBOBJECTS_IO_H_INCLUDED |
8 | #define DOC_SUBOBJECTS_IO_H_INCLUDED |
9 | #pragma once |
10 | |
11 | #include "doc/cel_data.h" |
12 | #include "doc/image_ref.h" |
13 | |
14 | #include <iosfwd> |
15 | #include <map> |
16 | |
17 | namespace doc { |
18 | class Sprite; |
19 | |
20 | class SubObjectsIO { |
21 | public: |
22 | virtual ~SubObjectsIO() { } |
23 | virtual ImageRef getImageRef(ObjectId imageId) = 0; |
24 | virtual CelDataRef getCelDataRef(ObjectId celdataId) = 0; |
25 | }; |
26 | |
27 | // Helper class used to read children-objects by layers and cels. |
28 | class SubObjectsFromSprite : public SubObjectsIO { |
29 | public: |
30 | SubObjectsFromSprite(Sprite* sprite); |
31 | |
32 | Sprite* sprite() const { return m_sprite; } |
33 | |
34 | void addImageRef(const ImageRef& image); |
35 | void addCelDataRef(const CelDataRef& celdata); |
36 | |
37 | ImageRef getImageRef(ObjectId imageId) override; |
38 | CelDataRef getCelDataRef(ObjectId celdataId) override; |
39 | |
40 | private: |
41 | Sprite* m_sprite; |
42 | |
43 | // Images list that can be queried from doc::read_celdata() using |
44 | // getImageRef(). |
45 | std::map<ObjectId, ImageRef> m_images; |
46 | |
47 | // CelData list that can be queried from doc::read_cel() using |
48 | // getCelDataRef(). |
49 | std::map<ObjectId, CelDataRef> m_celdatas; |
50 | }; |
51 | |
52 | } // namespace doc |
53 | |
54 | #endif |
55 | |