1 #ifndef _KVI_KVS_OBJECT_CONTROLLER_H_
2 #define _KVI_KVS_OBJECT_CONTROLLER_H_
3 //=============================================================================
4 //
5 //   File : KviKvsObjectController.h
6 //   Creation date : Sun 24 Apr 2005 05:23:04 by Szymon Stefanek
7 //
8 //   This file is part of the KVIrc IRC client distribution
9 //   Copyright (C) 2005-2010 Szymon Stefanek <pragma at kvirc dot net>
10 //
11 //   This program is FREE software. You can redistribute it and/or
12 //   modify it under the terms of the GNU General Public License
13 //   as published by the Free Software Foundation; either version 2
14 //   of the License, or (at your option) any later version.
15 //
16 //   This program is distributed in the HOPE that it will be USEFUL,
17 //   but WITHOUT ANY WARRANTY; without even the implied warranty of
18 //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 //   See the GNU General Public License for more details.
20 //
21 //   You should have received a copy of the GNU General Public License
22 //   along with this program. If not, write to the Free Software Foundation,
23 //   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 //
25 //=============================================================================
26 
27 #include "kvi_settings.h"
28 
29 #include "KviQString.h"
30 #include "KviPointerList.h"
31 
32 #include "KviPointerHashTable.h"
33 
34 #include "KviKvsObject.h"
35 #include "KviKvsObjectClass.h"
36 
37 class KVIRC_API KviKvsObjectController
38 {
39 	friend class KviKvsObject;
40 	friend class KviKvsObjectClass;
41 
42 public:
43 	KviKvsObjectController();
44 	~KviKvsObjectController();
45 
46 protected:
47 	KviPointerList<KviKvsObject> * m_pTopLevelObjectList;
48 	KviPointerHashTable<void *, KviKvsObject> * m_pObjectDict;
49 	KviPointerHashTable<QString, KviKvsObjectClass> * m_pClassDict;
50 	KviKvsObjectClass * m_pObjectClass = nullptr; //base class
51 protected:
52 	// the classes and the objects register themselves with the controller
53 	void registerObject(KviKvsObject * pObject);
54 	void unregisterObject(KviKvsObject * pObject);
55 	void registerClass(KviKvsObjectClass * pClass);
56 	void unregisterClass(KviKvsObjectClass * pClass);
57 
58 public:
59 	void init();
60 	void deleteClass(KviKvsObjectClass * pClass);
61 	void clearInstances();
62 	void clearUserClasses();
63 	void flushUserClasses();
64 	void killAllObjectsWithClass(KviKvsObjectClass * pClass);
65 	KviKvsObjectClass * lookupClass(const QString & szClass, bool bBuiltinOnly = false);
lookupObject(kvs_hobject_t hObject)66 	KviKvsObject * lookupObject(kvs_hobject_t hObject) { return m_pObjectDict->find(hObject); };
objectDict()67 	KviPointerHashTable<void *, KviKvsObject> * objectDict() { return m_pObjectDict; };
classDict()68 	KviPointerHashTable<QString, KviKvsObjectClass> * classDict() { return m_pClassDict; };
69 };
70 
71 #endif //!_KVI_KVS_OBJECT_CONTROLLER_H_
72