aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2007-03-17 10:36:14 +0000
committerMax Horn2007-03-17 10:36:14 +0000
commit97514214349ed236c54fa6a91a0937b9c6073aab (patch)
tree0d1034f07270c91d629bdd5b62ff81f1bb2a20e8
parentc1f4dbda7794fbc174668def400cbfe315f71f51 (diff)
downloadscummvm-rg350-97514214349ed236c54fa6a91a0937b9c6073aab.tar.gz
scummvm-rg350-97514214349ed236c54fa6a91a0937b9c6073aab.tar.bz2
scummvm-rg350-97514214349ed236c54fa6a91a0937b9c6073aab.zip
Added class NonCopyable, and made various things derive from it
svn-id: r26163
-rw-r--r--common/events.h5
-rw-r--r--common/noncopyable.h43
-rw-r--r--common/savefile.h3
-rw-r--r--common/singleton.h5
-rw-r--r--common/system.h8
-rw-r--r--common/timer.h3
6 files changed, 55 insertions, 12 deletions
diff --git a/common/events.h b/common/events.h
index 443903896e..201faa977c 100644
--- a/common/events.h
+++ b/common/events.h
@@ -25,6 +25,7 @@
#include "common/rect.h"
#include "common/system.h"
+#include "common/noncopyable.h"
namespace Common {
@@ -33,7 +34,7 @@ namespace Common {
* In addition, it keeps track of the state of various input devices,
* like keys, mouse position and buttons.
*/
-class EventManager {
+class EventManager : NonCopyable {
public:
EventManager() {}
virtual ~EventManager() {}
@@ -79,6 +80,6 @@ public:
// replacing it by a generic getScreenChangeID method here
};
-}
+} // End of namespace Common
#endif
diff --git a/common/noncopyable.h b/common/noncopyable.h
new file mode 100644
index 0000000000..7fafc44121
--- /dev/null
+++ b/common/noncopyable.h
@@ -0,0 +1,43 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2002-2007 The ScummVM project
+ *
+ * This program 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.
+
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef COMMON_NONCOPYABLE_H
+#define COMMON_NONCOPYABLE_H
+
+namespace Common {
+
+/**
+ * Subclass of NonCopyable can not be copied due to the fact that
+ * we made the copy constructor and assigment operator private.
+ */
+class NonCopyable {
+public:
+ NonCopyable() {}
+private:
+ // Prevent copying instances by accident
+ NonCopyable(const NonCopyable&);
+ NonCopyable& operator= (const NonCopyable&);
+};
+
+} // End of namespace Common
+
+#endif
diff --git a/common/savefile.h b/common/savefile.h
index 4dbb46c5eb..9d781b92f8 100644
--- a/common/savefile.h
+++ b/common/savefile.h
@@ -24,6 +24,7 @@
#define COMMON_SAVEFILE_H
#include "common/stdafx.h"
+#include "common/noncopyable.h"
#include "common/scummsys.h"
#include "common/stream.h"
@@ -70,7 +71,7 @@ public:
* it is effectively used as such, with OSystem::getSavefileManager
* returning the single SaveFileManager instances to be used.
*/
-class SaveFileManager {
+class SaveFileManager : NonCopyable {
public:
virtual ~SaveFileManager() {}
diff --git a/common/singleton.h b/common/singleton.h
index 75acb9e668..5e72e72230 100644
--- a/common/singleton.h
+++ b/common/singleton.h
@@ -24,14 +24,15 @@
#ifndef COMMON_SINGLETON_H
#define COMMON_SINGLETON_H
+#include "common/noncopyable.h"
+
namespace Common {
/**
* Generic template base class for implementing the singleton design pattern.
*/
template <class T>
-class Singleton
-{
+class Singleton : NonCopyable {
private:
Singleton<T>(const Singleton<T>&);
Singleton<T>& operator= (const Singleton<T>&);
diff --git a/common/system.h b/common/system.h
index 53a545627c..b9e46906f8 100644
--- a/common/system.h
+++ b/common/system.h
@@ -26,6 +26,7 @@
#include "common/scummsys.h"
#include "common/mutex.h"
+#include "common/noncopyable.h"
#include "common/rect.h"
namespace Audio {
@@ -52,12 +53,7 @@ namespace Common {
* methods to create timers, to handle user input events,
* control audio CD playback, and sound output.
*/
-class OSystem {
-private:
- // Prevent copying OSystem objects by accident.
- OSystem(const OSystem&);
- OSystem& operator= (const OSystem&);
-
+class OSystem : Common::NonCopyable {
protected:
OSystem();
virtual ~OSystem();
diff --git a/common/timer.h b/common/timer.h
index 7f660e7742..30a733aaee 100644
--- a/common/timer.h
+++ b/common/timer.h
@@ -23,10 +23,11 @@
#define COMMON_TIMER_H
#include "common/scummsys.h"
+#include "common/noncopyable.h"
namespace Common {
-class TimerManager {
+class TimerManager : NonCopyable {
public:
typedef void (*TimerProc)(void *refCon);