]> git.cworth.org Git - vogl/blob - src/vogleditor/vogleditor_snapshotitem.h
Initial vogl checkin
[vogl] / src / vogleditor / vogleditor_snapshotitem.h
1 /**************************************************************************
2  *
3  * Copyright 2013-2014 RAD Game Tools and Valve Software
4  * All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  *
24  **************************************************************************/
25
26 #ifndef VOGLEDITOR_SNAPSHOTITEM_H
27 #define VOGLEDITOR_SNAPSHOTITEM_H
28
29 #include <QList>
30
31 // external classes (could be predeclared)
32 #include "vogl_common.h"
33 #include "vogleditor_gl_state_snapshot.h"
34
35 // base class for items that might have a snapshot
36 class vogleditor_snapshotItem
37 {
38 public:
39     vogleditor_snapshotItem()
40         : m_pSnapshot(NULL)
41     {
42     }
43
44     virtual ~vogleditor_snapshotItem()
45     {
46         if (m_pSnapshot != NULL)
47         {
48            vogl_delete(m_pSnapshot);
49            m_pSnapshot = NULL;
50         }
51     }
52
53     virtual bool needs_snapshot()
54     {
55         if (has_snapshot() && get_snapshot()->is_valid())
56             return false;
57
58         return true;
59     }
60
61     virtual void set_snapshot(vogleditor_gl_state_snapshot* pSnapshot)
62     {
63        if (m_pSnapshot != NULL)
64        {
65           vogl_delete(m_pSnapshot);
66        }
67
68        m_pSnapshot = pSnapshot;
69     }
70
71     virtual bool has_snapshot() const
72     {
73        return (m_pSnapshot != NULL);
74     }
75
76     virtual vogleditor_gl_state_snapshot* get_snapshot() const
77     {
78        return m_pSnapshot;
79     }
80
81 private:
82     vogleditor_gl_state_snapshot* m_pSnapshot;
83 };
84
85 #endif // VOGLEDITOR_SNAPSHOTITEM_H