1 #ifndef VOGLEDITOR_STATETREECONTEXTINFOITEM_H
2 #define VOGLEDITOR_STATETREECONTEXTINFOITEM_H
4 #include "vogleditor_statetreeitem.h"
6 class vogleditor_stateTreeContextInfoDiffableItem : public vogleditor_stateTreeItem
9 vogleditor_stateTreeContextInfoDiffableItem(QString name, QString value, vogleditor_stateTreeItem* parent)
10 : vogleditor_stateTreeItem(name, value, parent),
11 m_pDiffBaseState(NULL)
15 void set_diff_base_state(const vogl_context_info* pBaseState) {
16 m_pDiffBaseState = pBaseState;
19 virtual bool hasChanged() const = 0;
21 const vogl_context_info* m_pDiffBaseState;
24 class vogleditor_stateTreeContextInfoBoolItem : public vogleditor_stateTreeContextInfoDiffableItem
27 vogleditor_stateTreeContextInfoBoolItem(QString name, bool (vogl_context_info::* func)(void) const, vogleditor_stateTreeItem* parent, const vogl_context_info& info);
28 virtual ~vogleditor_stateTreeContextInfoBoolItem() { m_pState = NULL; }
30 const vogl_context_info* get_context_info() const { return m_pState; }
31 virtual bool hasChanged() const;
32 virtual QString getDiffedValue() const;
35 const vogl_context_info* m_pState;
36 bool (vogl_context_info::* m_pFunc)(void) const;
39 class vogleditor_stateTreeContextInfoUIntItem : public vogleditor_stateTreeContextInfoDiffableItem
42 vogleditor_stateTreeContextInfoUIntItem(QString name, uint (vogl_context_info::* func)(void) const, vogleditor_stateTreeItem* parent, const vogl_context_info& info);
43 virtual ~vogleditor_stateTreeContextInfoUIntItem() { m_pState = NULL; }
45 const vogl_context_info* get_context_info() const { return m_pState; }
46 virtual bool hasChanged() const;
47 virtual QString getDiffedValue() const;
50 const vogl_context_info* m_pState;
51 uint (vogl_context_info::* m_pFunc)(void) const;
55 class vogleditor_stateTreeContextInfoStringItem : public vogleditor_stateTreeContextInfoDiffableItem
58 vogleditor_stateTreeContextInfoStringItem(QString name, const vogl::dynamic_string& (vogl_context_info::* func)(void) const, vogleditor_stateTreeItem* parent, const vogl_context_info& info);
59 virtual ~vogleditor_stateTreeContextInfoStringItem() { m_pState = NULL;}
61 const vogl_context_info* get_context_info() const { return m_pState; }
62 virtual bool hasChanged() const;
63 virtual QString getDiffedValue() const;
66 const vogl_context_info* m_pState;
67 dynamic_string m_value;
68 const vogl::dynamic_string& (vogl_context_info::* m_pFunc)(void) const;
71 class vogleditor_stateTreeContextInfoExtensionItem : public vogleditor_stateTreeContextInfoDiffableItem
74 vogleditor_stateTreeContextInfoExtensionItem(QString name, const vogl::dynamic_string extensionName, vogleditor_stateTreeItem* parent, const vogl_context_info& info)
75 : vogleditor_stateTreeContextInfoDiffableItem(name, QString(extensionName.c_str()), parent),
77 m_extensionName(extensionName)
79 setValue(QString(extensionName.c_str()));
82 virtual ~vogleditor_stateTreeContextInfoExtensionItem() { m_pState = NULL; }
84 const vogl_context_info* get_context_info() const { return m_pState; }
85 virtual bool hasChanged() const
87 if (m_pDiffBaseState == NULL)
92 // if the current extension is in the base list, then don't flag this as having changed
93 const dynamic_string_array& baseExtensions = m_pDiffBaseState->get_extensions();
94 for (const vogl::dynamic_string* iter = baseExtensions.begin(); iter != baseExtensions.end(); iter++)
96 if ((*iter) == m_extensionName)
102 // if we've made it through the entire list, then this extension was not in the base context, so it is new (has changed).
106 // if an extension shows up as having changed, that means it didn't exist in the previous snapshot
107 virtual QString getDiffedValue() const { return "non-existent"; }
110 const vogl_context_info* m_pState;
111 dynamic_string m_extensionName;
114 class vogleditor_stateTreeContextInfoItem : public vogleditor_stateTreeItem
117 vogleditor_stateTreeContextInfoItem(QString name, QString value, vogleditor_stateTreeItem* parent, const vogl_context_info& info);
118 virtual ~vogleditor_stateTreeContextInfoItem()
120 m_pState = NULL; m_pDiffBaseState = NULL;
123 const vogl_context_info* get_context_info() const { return m_pState; }
125 void set_diff_base_state(const vogl_context_info* pBaseState) {
126 m_pDiffBaseState = pBaseState;
127 for (vogleditor_stateTreeContextInfoDiffableItem** iter = m_diffableItems.begin(); iter != m_diffableItems.end(); iter++)
129 (*iter)->set_diff_base_state(pBaseState);
132 virtual bool hasChanged() const;
135 const vogl_context_info* m_pState;
136 const vogl_context_info* m_pDiffBaseState;
137 vogl::vector<vogleditor_stateTreeContextInfoDiffableItem*> m_diffableItems;
140 #endif // VOGLEDITOR_STATETREECONTEXTINFOITEM_H