Version: 0.6.0
gxobject.h
1 /******************************************************************************
2  * Project: wxGIS (GIS Catalog)
3  * Purpose: wxGxObject.
4  * Author: Dmitry Baryshnikov (aka Bishop), polimax@mail.ru
5  ******************************************************************************
6 * Copyright (C) 2012 Dmitry Baryshnikov
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  ****************************************************************************/
21 #pragma once
22 
23 #include "wxgis/catalog/catalog.h"
24 
25 #include <wx/event.h>
26 #include <wx/list.h>
27 
28 #include <map>
29 
37 class WXDLLIMPEXP_GIS_CLT wxGxObject :
38  public wxEvtHandler
39 {
40  wxDECLARE_ABSTRACT_CLASS(wxGxObject);
41 public:
42  wxGxObject(void);
43  wxGxObject(wxGxObject *oParent, const wxString &soName = wxEmptyString, const CPLString &soPath = "");
44  virtual ~wxGxObject(void);
45  virtual bool Create(wxGxObject *oParent = NULL, const wxString &soName = wxEmptyString, const CPLString &soPath = "");
46  virtual bool Destroy(void);
47  virtual void SetParent(wxGxObject *oParent);
48  virtual wxString GetName(void) const;
49  virtual CPLString GetPath(void) const;
50  virtual void SetName(const wxString &soName);
51  virtual void SetPath(const CPLString &soPath);
52  //the GxObject name without extension
53  virtual wxString GetBaseName(void) const;
54  virtual wxString GetFullName(void) const;
55  virtual wxString GetCategory(void) const;
56  virtual wxGxObject *GetParent(void) const;
57  virtual void Refresh(void);
58  virtual long GetId(void) const {return m_nId;};
59  virtual void SetId(long nId){m_nId = nId;};
60  virtual wxGxObject *FindGxObjectByPath(const wxString &sPath); //search by Path stored in CPLString sPath
61  virtual wxGxObject *FindGxObject(const wxString &sPath); //search by Name stored in wxString sName
62 protected:
63  wxString m_sName;
64  CPLString m_sPath;
65  wxGxObject *m_oParent;
66  long m_nId;
67 };
68 
69 WX_DECLARE_LIST_2(wxGxObject, wxGxObjectList, wxGxObjectListNode, class WXDLLIMPEXP_GIS_CLT);
70 
78 class WXDLLIMPEXP_GIS_CLT wxGxObjectContainer : public wxGxObject
79 {
80  wxDECLARE_ABSTRACT_CLASS(wxGxObjectContainer);
81 public:
82  wxGxObjectContainer(void);
83  wxGxObjectContainer(wxGxObject *oParent, const wxString &soName = wxEmptyString, const CPLString &soPath = "");
84  virtual ~wxGxObjectContainer(void);
85  virtual void AddChild( wxGxObject *child );
86  virtual void RemoveChild( wxGxObject *child );
87  virtual bool DestroyChild( wxGxObject *child );
88  virtual bool IsNameExist(const wxString &sName) const;
89  virtual bool DestroyChildren();
90  virtual bool HasChildren(void);
91  virtual bool AreChildrenViewable(void) const = 0;
92  virtual const wxGxObjectList& GetChildren() const;
93  virtual bool CanCreate(long nDataType, long DataSubtype);
94  //wxGxObject
95  virtual bool Destroy(void);
96  virtual wxGxObjectList& GetChildren();
97  virtual void Refresh(void);
98  virtual wxGxObject *FindGxObjectByPath(const wxString &sPath);
99  virtual wxGxObject *FindGxObject(const wxString &sPath);
100 protected:
101  wxGxObjectList m_Children;
102 };
103 
111 class WXDLLIMPEXP_GIS_CLT wxGxCatalogBase : public wxGxObjectContainer
112 {
113  wxDECLARE_ABSTRACT_CLASS(wxGxCatalogBase);
114 public:
115  wxGxCatalogBase(wxGxObject *oParent = NULL, const wxString &soName = _("Catalog"), const CPLString &soPath = "");
116  virtual ~wxGxCatalogBase(void);
117  //wxGxObject
118  virtual wxString GetFullName(void) const;
119  virtual wxString GetCategory(void) const;
120  //wxGxObjectContainer
121  virtual bool AreChildrenViewable(void) const;
122  //wxGxCatalog
123  virtual wxString ConstructFullName(const wxGxObject* pObject) const;
124  virtual bool Destroy(void);
125  //register / unregister pointer and uniq ID
126  virtual void RegisterObject(wxGxObject* pObj);
127  virtual void UnRegisterObject(long nId);
128  //get pointer by ID
129  virtual wxGxObject* const GetRegisterObject(long nId);
130  //Initialization
131  virtual bool Init(void);
132  //
133  virtual bool GetShowHidden(void) const;
134  virtual bool GetShowExt(void) const;
135  virtual void SetShowHidden(bool bShowHidden);
136  virtual void SetShowExt(bool bShowExt);
137  //gxobject children factory
138  virtual bool CreateChildren(wxGxObject* pParent, char** &pFileNames, wxArrayLong & pChildrenIds) = 0;
139  //events
140  virtual void ObjectAdded(long nObjectID) = 0;
141  virtual void ObjectChanged(long nObjectID) = 0;
142  virtual void ObjectDeleted(long nObjectID) = 0;
143  virtual void ObjectRefreshed(long nObjectID) = 0;
144 protected:
145  virtual wxString GetConfigName(void) const = 0;
146  virtual void LoadObjectFactories() = 0;
147  virtual void LoadChildren() = 0;
148 protected:
149  long m_nGlobalId;
150  std::map<long, wxGxObject*> m_moGxObject; //map of registered IGxObject pointers
151  bool m_bIsInitialized;
152  bool m_bShowHidden, m_bShowExt;
153 };
154 
159 WXDLLIMPEXP_GIS_CLT wxGxCatalogBase* const GetGxCatalog(void);
160 
166 WXDLLIMPEXP_GIS_CLT void SetGxCatalog(wxGxCatalogBase* pCat);
167 
Definition: gxobject.h:111
Definition: gxobject.h:78
Definition: gxobject.h:37