summaryrefslogtreecommitdiff
path: root/plugins/Boltun/src/config.h
diff options
context:
space:
mode:
authorVadim Dashevskiy <watcherhd@gmail.com>2012-07-09 06:47:31 +0000
committerVadim Dashevskiy <watcherhd@gmail.com>2012-07-09 06:47:31 +0000
commitf17646aaa5e410a2e673e0de69358c9d5e09f63b (patch)
treeaa073350289525784c564cb8113444e97593a8d9 /plugins/Boltun/src/config.h
parent1156918f875f44ed97def4d3de8659e5782abfba (diff)
Boltun: changed folder structure
git-svn-id: http://svn.miranda-ng.org/main/trunk@866 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Boltun/src/config.h')
-rw-r--r--plugins/Boltun/src/config.h157
1 files changed, 157 insertions, 0 deletions
diff --git a/plugins/Boltun/src/config.h b/plugins/Boltun/src/config.h
new file mode 100644
index 0000000000..c5bb20e700
--- /dev/null
+++ b/plugins/Boltun/src/config.h
@@ -0,0 +1,157 @@
+//***********************************************************
+// Copyright © 2003-2008 Alexander S. Kiselev, Valentin Pavlyuchenko
+//
+// This file is part of Boltun.
+//
+// Boltun is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 2 of the License, or
+// (at your option) any later version.
+//
+// Boltun is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Boltun. If not, see <http://www.gnu.org/licenses/>.
+//
+//***********************************************************
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+
+#include <tchar.h>
+
+class BoltunConfig;
+
+template <class T, class BaseClass>
+class Property
+{
+public:
+ typedef const T (__thiscall BaseClass::*Getter)();
+ typedef const T (__thiscall BaseClass::*Setter)(const T);
+private:
+ const Getter getter;
+ const Setter setter;
+ BaseClass* owner;
+ bool cacheValid;
+ T cached;
+public:
+ Property(Getter g, Setter s)
+ :getter(g), setter(s), cacheValid(false)
+ {
+ }
+
+ void SetOwner(BaseClass* o)
+ {
+ owner = o;
+ }
+
+ inline operator const T()
+ {
+ if (cacheValid)
+ return cached;
+ cached = (owner->*getter)();
+ cacheValid = true;
+ return cached;
+ }
+
+ inline const T operator= (const T& value)
+ {
+ cacheValid = true;
+ return (owner->*setter)(cached = value);
+ }
+};
+
+template <class T, class BaseClass>
+class PtrProperty
+{
+public:
+ typedef const T* (__thiscall BaseClass::*Getter)();
+ typedef const T* (__thiscall BaseClass::*Setter)(const T*);
+private:
+ const Getter getter;
+ const Setter setter;
+ BaseClass* owner;
+ bool cacheValid;
+ const T* cached;
+public:
+ PtrProperty(Getter g, Setter s)
+ :getter(g), setter(s), cacheValid(false), cached(NULL)
+ {
+ }
+
+ ~PtrProperty()
+ {
+ delete cached;
+ }
+
+ void SetOwner(BaseClass* o)
+ {
+ owner = o;
+ }
+
+ inline operator const T*()
+ {
+ if (cacheValid)
+ return cached;
+ cached = (owner->*getter)();
+ cacheValid = true;
+ return cached;
+ }
+
+ inline const T* operator= (const T* value)
+ {
+ cacheValid = true;
+ delete cached;
+ cached = (owner->*setter)(value);
+ return cached;
+ }
+};
+
+class _BoltunConfigInit;
+
+#define BUILDDEFETTERS(x, typ) \
+ const typ Get##x(); \
+ const typ Set##x(const typ value);
+
+class BoltunConfig
+{
+ BUILDDEFETTERS(TalkWithEverybody, bool);
+ BUILDDEFETTERS(TalkWithNotInList, bool);
+ BUILDDEFETTERS(TalkWarnContacts, bool);
+ BUILDDEFETTERS(TalkEveryoneWhileAway, bool);
+ BUILDDEFETTERS(MarkAsRead, bool);
+ BUILDDEFETTERS(AnswerPauseTime, int);
+ BUILDDEFETTERS(AnswerThinkTime, int);
+ BUILDDEFETTERS(PauseDepends, bool);
+ BUILDDEFETTERS(PauseRandom, bool);
+ BUILDDEFETTERS(WarnText, TCHAR*);
+ BUILDDEFETTERS(MindFileName, TCHAR*);
+ BUILDDEFETTERS(EngineStaySilent, bool);
+ BUILDDEFETTERS(EngineMakeLowerCase, bool);
+ BUILDDEFETTERS(EngineUnderstandAlways, bool);
+ BoltunConfig();
+ ~BoltunConfig();
+ friend class _BoltunConfigInit;
+public:
+ Property<bool, BoltunConfig> TalkWithEverybody;
+ Property<bool, BoltunConfig> TalkWithNotInList;
+ Property<bool, BoltunConfig> TalkWarnContacts;
+ Property<bool, BoltunConfig> TalkEveryoneWhileAway;
+ Property<bool, BoltunConfig> MarkAsRead;
+ Property<int, BoltunConfig> AnswerPauseTime;
+ Property<int, BoltunConfig> AnswerThinkTime;
+ Property<bool, BoltunConfig> PauseDepends;
+ Property<bool, BoltunConfig> PauseRandom;
+ PtrProperty<TCHAR, BoltunConfig> WarnText;
+ PtrProperty<TCHAR, BoltunConfig> MindFileName;
+ Property<bool, BoltunConfig> EngineStaySilent;
+ Property<bool, BoltunConfig> EngineMakeLowerCase;
+ Property<bool, BoltunConfig> EngineUnderstandAlways;
+};
+
+extern BoltunConfig &Config;
+
+#endif /* _CONFIG_H */ \ No newline at end of file