1 | // Aseprite Document Library |
2 | // Copyright (c) 2017 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_SLICES_H_INCLUDED |
8 | #define DOC_SLICES_H_INCLUDED |
9 | #pragma once |
10 | |
11 | #include "base/disable_copying.h" |
12 | #include "doc/object_id.h" |
13 | |
14 | #include <string> |
15 | #include <vector> |
16 | |
17 | namespace doc { |
18 | |
19 | class Slice; |
20 | class Sprite; |
21 | |
22 | class Slices { |
23 | typedef std::vector<Slice*> List; |
24 | |
25 | public: |
26 | typedef List::iterator iterator; |
27 | typedef List::const_iterator const_iterator; |
28 | |
29 | Slices(Sprite* sprite); |
30 | ~Slices(); |
31 | |
32 | Sprite* sprite() { return m_sprite; } |
33 | |
34 | void add(Slice* slice); |
35 | void remove(Slice* slice); |
36 | |
37 | Slice* getByName(const std::string& name) const; |
38 | Slice* getById(const ObjectId id) const; |
39 | |
40 | iterator begin() { return m_slices.begin(); } |
41 | iterator end() { return m_slices.end(); } |
42 | const_iterator begin() const { return m_slices.begin(); } |
43 | const_iterator end() const { return m_slices.end(); } |
44 | |
45 | std::size_t size() const { return m_slices.size(); } |
46 | bool empty() const { return m_slices.empty(); } |
47 | |
48 | private: |
49 | Sprite* m_sprite; |
50 | List m_slices; |
51 | |
52 | DISABLE_COPYING(Slices); |
53 | }; |
54 | |
55 | } // namespace doc |
56 | |
57 | #endif |
58 | |