]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/itemid.h
Deallocate wxThreadSpecificInfo when wxThread ends.
[wxWidgets.git] / include / wx / itemid.h
... / ...
CommitLineData
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/itemid.h
3// Purpose: wxItemId class declaration.
4// Author: Vadim Zeitlin
5// Created: 2011-08-17
6// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
7// Licence: wxWindows licence
8///////////////////////////////////////////////////////////////////////////////
9
10#ifndef _WX_ITEMID_H_
11#define _WX_ITEMID_H_
12
13// ----------------------------------------------------------------------------
14// wxItemId: an opaque item identifier used with wx{Tree,TreeList,DataView}Ctrl.
15// ----------------------------------------------------------------------------
16
17// The template argument T is typically a pointer to some opaque type. While
18// wxTreeItemId and wxDataViewItem use a pointer to void, this is dangerous and
19// not recommended for the new item id classes.
20template <typename T>
21class wxItemId
22{
23public:
24 typedef T Type;
25
26 // This ctor is implicit which is fine for non-void* types, but if you use
27 // this class with void* you're strongly advised to make the derived class
28 // ctor explicit as implicitly converting from any pointer is simply too
29 // dangerous.
30 wxItemId(Type item = NULL) : m_pItem(item) { }
31
32 // Default copy ctor, assignment operator and dtor are ok.
33
34 bool IsOk() const { return m_pItem != NULL; }
35 Type GetID() const { return m_pItem; }
36 operator const Type() const { return m_pItem; }
37
38 // This is used for implementation purposes only.
39 Type operator->() const { return m_pItem; }
40
41 void Unset() { m_pItem = NULL; }
42
43 // This field is public *only* for compatibility with the old wxTreeItemId
44 // implementation and must not be used in any new code.
45//private:
46 Type m_pItem;
47};
48
49template <typename T>
50bool operator==(const wxItemId<T>& left, const wxItemId<T>& right)
51{
52 return left.GetID() == right.GetID();
53}
54
55template <typename T>
56bool operator!=(const wxItemId<T>& left, const wxItemId<T>& right)
57{
58 return !(left == right);
59}
60
61#endif // _WX_ITEMID_H_