forked from aseprite/aseprite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
object.h
60 lines (44 loc) · 1.26 KB
/
object.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Aseprite Document Library
// Copyright (c) 2001-2015 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
#ifndef DOC_OBJECT_H_INCLUDED
#define DOC_OBJECT_H_INCLUDED
#pragma once
#include "doc/object_id.h"
#include "doc/object_type.h"
#include "doc/object_version.h"
namespace doc {
class Object {
public:
Object(ObjectType type);
Object(const Object& other);
virtual ~Object();
const ObjectType type() const { return m_type; }
const ObjectId id() const;
const ObjectVersion version() const { return m_version; }
void setId(ObjectId id);
void setVersion(ObjectVersion version);
void incrementVersion() {
++m_version;
}
// Returns the approximate amount of memory (in bytes) which this
// object use.
virtual int getMemSize() const;
private:
ObjectType m_type;
// Unique identifier for this object (it is assigned by
// Objects class).
mutable ObjectId m_id;
ObjectVersion m_version;
// Disable copy assignment
Object& operator=(const Object&);
};
Object* get_object(ObjectId id);
template<typename T>
inline T* get(ObjectId id) {
return static_cast<T*>(get_object(id));
}
} // namespace doc
#endif