Version: 0.6.0
gxcatalog.h
1 /******************************************************************************
2  * Project: wxGIS (GIS Catalog)
3  * Purpose: wxGxCatalog class.
4  * Author: Dmitry Baryshnikov (aka Bishop), polimax@mail.ru
5  ******************************************************************************
6 * Copyright (C) 2009-2014 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/gxobject.h"
24 #include "wxgis/catalog/gxobjectfactory.h"
25 #include "wxgis/core/pointer.h"
26 
27 #include <wx/xml/xml.h>
28 #include <wx/event.h>
29 #include <wx/fswatcher.h>
30 
31 #if wxVERSION_NUMBER <= 2903// && !defined EVT_FSWATCHER(winid, func)
32 #define EVT_FSWATCHER(winid, func) \
33  wx__DECLARE_EVT1(wxEVT_FSWATCHER, winid, wxFileSystemWatcherEventHandler(func))
34 #endif
35 
42 class WXDLLIMPEXP_GIS_CLT wxGxCatalog :
43  public wxGxCatalogBase,
45 {
46  wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxGxCatalog);
47 public:
48  wxGxCatalog(wxGxObject *oParent = NULL, const wxString &soName = _("Catalog"), const CPLString &soPath = "");
49  virtual ~wxGxCatalog(void);
50  virtual void ObjectAdded(long nObjectID);
51  virtual void ObjectChanged(long nObjectID);
52  virtual void ObjectDeleted(long nObjectID);
53  virtual void ObjectRefreshed(long nObjectID);
54  virtual bool CreateChildren(wxGxObject* pParent, char** &pFileNames, wxArrayLong & pChildrenIds);
55  virtual void EnableRootItem(size_t nItemId, bool bEnable);
56  virtual bool Destroy(void);
57  virtual wxGxObject* const GetRootItemByType(const wxClassInfo * info) const;
58  virtual wxGxObjectFactory* const GetObjectFactoryByClassName(const wxString &sClassName);
59  virtual wxGxObjectFactory* const GetObjectFactoryByName(const wxString &sFactoryName);
60 
61  typedef struct _root_item{
62  wxString sClassName;
63  wxString sName;
64  bool bEnabled;
65  wxXmlNode* pConfig;
66  } ROOTITEM;
67 
68  virtual wxVector<wxGxCatalog::ROOTITEM>* const GetRootItems(void);
69  virtual wxVector<wxGxObjectFactory*>* const GetObjectFactories(void);
70  //watcher
71  virtual bool AddFSWatcherPath(const wxFileName& path, int events = wxFSW_EVENT_ALL);
72  virtual bool AddFSWatcherTree(const wxFileName& path, int events = wxFSW_EVENT_ALL, const wxString& filespec = wxEmptyString);
73  virtual bool RemoveFSWatcherPath(const wxFileName& path);
74  virtual bool RemoveFSWatcherTree(const wxFileName& path);
75  virtual void StopFSWatcher();
76  virtual void StartFSWatcher();
77 //events
78  virtual void OnFileSystemEvent(wxFileSystemWatcherEvent& event);
79 protected:
80  //wxGxCatalogBase
81  virtual void LoadObjectFactories(const wxXmlNode* pNode);
82  virtual void LoadObjectFactories(void);
83  virtual void LoadChildren(void);
84  virtual void LoadChildren(wxXmlNode* const pNode);
85  virtual void EmptyObjectFactories(void);
86  virtual void SerializePlugins(wxXmlNode* pNode, bool bStore = false);
87 protected:
88  virtual wxString GetConfigName(void) const {return wxString(wxT("wxCatalog"));};
89  virtual bool IsPathWatched(const wxString& sPath);
90 protected:
91  wxArrayString m_CatalogRootItemArray;
92  wxVector<wxGxObjectFactory*> m_ObjectFactoriesArray;
93  wxVector<ROOTITEM> m_staRootitems;
94 
95  wxFileSystemWatcher *m_pWatcher;
96  bool m_bFSWatcherEnable;
97 // wxArrayString m_asWatchPaths;
98  wxCriticalSection m_oCritFSSect;
99 private:
100  DECLARE_EVENT_TABLE()
101 };
102 
103 #define wxGIS_GXCATALOG_EVENT(x) { wxGxCatalogBase* pGxCatalog = GetGxCatalog(); \
104  if(pGxCatalog) pGxCatalog->x(GetId()); }
105 #define wxGIS_GXCATALOG_EVENT_ID(x, id) { wxGxCatalogBase* pGxCatalog = GetGxCatalog(); \
106  if(pGxCatalog) pGxCatalog->x(id); }
107 
108 
Definition: gxcatalog.h:42
Definition: pointer.h:34
Definition: gxobject.h:111
Definition: gxcatalog.h:61
A base class for GxObject factory.
Definition: gxobjectfactory.h:32
Definition: gxobject.h:37