KVIrc  4.9.2
DeveloperAPIs
KviKvsObjectClass.h
Go to the documentation of this file.
1 #ifndef _KVI_KVS_OBJECTCLASS_H_
2 #define _KVI_KVS_OBJECTCLASS_H_
3 //=============================================================================
4 //
5 // File : kvi_kvs_objectclass.h
6 // Creation date : Sat 23 Apr 2005 20:31:32 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 #include "KviQString.h"
29 #include "KviPointerList.h"
30 
31 #include "KviPointerHashTable.h"
32 
34 
35 class KviKvsObject;
36 class KviKvsObjectClass;
38 class KviKvsVariantList;
39 class KviKvsVariant;
40 // Object allocation function
41 // parameters are: the class, the parent object (eventually 0), the object name (eventually empty)
42 typedef KviKvsObject * (*KviKvsObjectAllocateInstanceProc)(KviKvsObjectClass *, KviKvsObject *, const QString &);
43 
44 // An object function callback
46 
47 // The descriptor of a kvirc object class
48 
50 {
51  friend class KviKvsObject;
52  friend class KviKvsObjectController;
53 
54 public:
56  KviKvsObjectClass * pParent, // parent class
57  const QString & szName, // class name
58  KviKvsObjectAllocateInstanceProc proc, // intance allocation proc
59  bool bBuiltin = true // this is a builtin or script based class ?
60  );
62 
63 protected:
64  KviKvsObjectClass * m_pParentClass; // the parent (base) class
65  QString m_szName; // the class name
66  bool m_bBuiltin; // is this a builtin or script based class ?
70  bool m_bDirty; // not yet flushed to disk (only for not builtin classes)
71 protected:
72  void registerChildClass(KviKvsObjectClass * pClass);
73  void unregisterChildClass(KviKvsObjectClass * pClass);
75 public:
76  void clearDirtyFlag() { m_bDirty = false; };
77  bool isDirty() { return m_bDirty; };
78  bool isBuiltin() { return m_bBuiltin; };
79  bool isScriptHandler(const QString & szFunctionName)
80  {
81  KviKvsObjectFunctionHandler * pFunctionHandler = m_pFunctionHandlers->find(szFunctionName);
82  if(pFunctionHandler)
83  return pFunctionHandler->isScriptHandler();
84  else
85  return false;
86  };
87  void setReminder(const QString & szReminder, KviKvsObjectFunctionHandler * h);
88  QString reminder(KviKvsObjectFunctionHandler * h);
89 
90  const QString & name() { return m_szName; };
91  KviKvsObjectClass * parentClass() { return m_pParentClass; };
92  // pProc CAN'T be zero here!
93  void registerFunctionHandler(const QString & szFunctionName, KviKvsObjectFunctionHandlerProc pProc, unsigned int uFlags = 0);
94  void registerFunctionHandler(const QString & szFunctionName, const QString & szBuffer, const QString & szReminder, unsigned int uFlags = 0);
95 
96  // registers an empty handler that returns "nothing"
97  void registerStandardNothingReturnFunctionHandler(const QString & szFunc);
98  // registers an empty handler that returns $true
99  void registerStandardTrueReturnFunctionHandler(const QString & szFunc);
100  // registers an empty handler that returns $false
101  void registerStandardFalseReturnFunctionHandler(const QString & szFunc);
102 
103  KviKvsObjectFunctionHandler * lookupFunctionHandler(const QString & szFunc) { return m_pFunctionHandlers->find(szFunc); };
104  KviKvsObject * allocateInstance(KviKvsObject * pParent, const QString & szName, KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams);
105 
106  bool save(const QString & szFileName);
107  static bool load(const QString & szFileName);
108  void getFunctionCode(QString & szCode, KviKvsObjectFunctionHandler & h);
110 };
111 
112 #endif
const QString & name()
Definition: KviKvsObjectClass.h:90
bool isScriptHandler(const QString &szFunctionName)
Definition: KviKvsObjectClass.h:79
KviPointerList< KviKvsObjectClass > * m_pChildClasses
Definition: KviKvsObjectClass.h:68
friend class KviKvsObjectClass
Definition: KviKvsObjectController.h:40
This class defines a new data type which contains variant data.
Definition: KviKvsVariant.h:351
#define KVIRC_API
Definition: kvi_settings.h:128
Class to handle variant variables lists.
Definition: KviKvsVariantList.h:41
Definition: KviKvsObjectController.h:37
Definition: KviKvsObjectFunctionCall.h:33
Definition: KviKvsObject.h:50
QString m_szName
Definition: KviKvsObjectClass.h:65
KviKvsObjectFunctionHandler * lookupFunctionHandler(const QString &szFunc)
Definition: KviKvsObjectClass.h:103
Definition: KviKvsObjectClass.h:49
bool(KviKvsObject::* KviKvsObjectFunctionHandlerProc)(KviKvsObjectFunctionCall *pCall)
Definition: KviKvsObjectClass.h:45
KviKvsObjectClass * m_pParentClass
Definition: KviKvsObjectClass.h:64
Pointer Hash Table.
virtual bool isScriptHandler()
Definition: KviKvsObjectFunctionHandler.cpp:36
#define h
Definition: detector.cpp:72
bool save(KviThemeInfo &options, bool bSaveIcons)
Definition: KviOptions.cpp:986
KviKvsObjectAllocateInstanceProc m_allocProc
Definition: KviKvsObjectClass.h:69
bool m_bBuiltin
Definition: KviKvsObjectClass.h:66
KviPointerHashTable< QString, KviKvsObjectFunctionHandler > * m_pFunctionHandlers
Definition: KviKvsObjectClass.h:67
KviKvsObjectClass * parentClass()
Definition: KviKvsObjectClass.h:91
bool m_bDirty
Definition: KviKvsObjectClass.h:70
C++ Template based double linked pointer list class.
Definition: KviKvsRunTimeContext.h:103
KviPointerHashTable< QString, KviKvsObjectFunctionHandler > * getHandlers()
Definition: KviKvsObjectClass.h:109
KviKvsObject *(* KviKvsObjectAllocateInstanceProc)(KviKvsObjectClass *, KviKvsObject *, const QString &)
Definition: KviKvsObjectClass.h:42
bool isBuiltin()
Definition: KviKvsObjectClass.h:78
bool isDirty()
Definition: KviKvsObjectClass.h:77
char szBuffer[4096]
Definition: winamp.cpp:77
This file contains compile time settings.
KviPointerHashTable< QString, KviKvsObjectFunctionHandler > * functionHandlers()
Definition: KviKvsObjectClass.h:74
Helper functions for the QString class.
Definition: KviKvsObjectFunctionHandler.h:34
void clearDirtyFlag()
Definition: KviKvsObjectClass.h:76