summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorGuillaume Melquiond <guillaume.melquiond@gmail.com>2006-07-27 17:20:22 +0000
committerGuillaume Melquiond <guillaume.melquiond@gmail.com>2006-07-27 17:20:22 +0000
commitd0b6b3d1c96e437d12410703a8e530decd0b028f (patch)
treef3568279aa6c31594f525f061efc6eda08278635 /src/utils
parent285b40d1cb768e235aed894f4704e1013cb054ea (diff)
downloadmanaserv-d0b6b3d1c96e437d12410703a8e530decd0b028f.tar.gz
manaserv-d0b6b3d1c96e437d12410703a8e530decd0b028f.tar.bz2
manaserv-d0b6b3d1c96e437d12410703a8e530decd0b028f.tar.xz
manaserv-d0b6b3d1c96e437d12410703a8e530decd0b028f.zip
First step toward a restructured class hierarchy for world actors: add
MovingObject and Player classes.
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/cipher.cpp3
-rw-r--r--src/utils/cipher.h5
-rw-r--r--src/utils/countedptr.h22
-rw-r--r--src/utils/logger.cpp4
-rw-r--r--src/utils/logger.h17
-rw-r--r--src/utils/singleton.h5
-rw-r--r--src/utils/stringfilter.cpp3
-rw-r--r--src/utils/stringfilter.h5
8 files changed, 20 insertions, 44 deletions
diff --git a/src/utils/cipher.cpp b/src/utils/cipher.cpp
index 6eda3ec5..083f6924 100644
--- a/src/utils/cipher.cpp
+++ b/src/utils/cipher.cpp
@@ -28,8 +28,6 @@
#include <openssl/evp.h>
#include <openssl/md5.h>
-namespace tmwserv
-{
namespace utils
{
@@ -95,4 +93,3 @@ Cipher::toHex(const unsigned char* str,
} // namespace utils
-} // namespace tmwserv
diff --git a/src/utils/cipher.h b/src/utils/cipher.h
index bfca4cb1..3dfb5ef2 100644
--- a/src/utils/cipher.h
+++ b/src/utils/cipher.h
@@ -28,9 +28,6 @@
#include "singleton.h"
-
-namespace tmwserv
-{
namespace utils
{
@@ -108,7 +105,5 @@ class Cipher: public Singleton<Cipher>
} // namespace utils
-} // namespace tmwserv
-
#endif // _TMWSERV_CIPHER_H_
diff --git a/src/utils/countedptr.h b/src/utils/countedptr.h
index f8dbcd51..3edc9c3d 100644
--- a/src/utils/countedptr.h
+++ b/src/utils/countedptr.h
@@ -24,9 +24,6 @@
#ifndef _TMWSERV_COUNTED_PTR_H_
#define _TMWSERV_COUNTED_PTR_H_
-
-namespace tmwserv
-{
namespace utils
{
@@ -84,6 +81,17 @@ class CountedPtr
++*count;
}
+ /**
+ * Copy pointer with static cast (one more owner).
+ */
+ template <typename U>
+ explicit CountedPtr(const CountedPtr<U>& p)
+ throw()
+ : ptr(static_cast<T*>(p.ptr)),
+ count(p.count)
+ {
+ ++*count;
+ }
/**
* Assignment (unshare old and share new value).
@@ -102,7 +110,6 @@ class CountedPtr
return *this;
}
-
/**
* Access the value to which the pointer refers.
*/
@@ -149,15 +156,12 @@ class CountedPtr
}
}
-
- private:
T* ptr; /**< pointer to the value */
long* count; /**< shared number of owners */
-};
+ template<typename U> friend class CountedPtr;
+};
} // namespace utils
-} // namespace tmwserv
-
#endif // _TMWSERV_COUNTED_PTR_H_
diff --git a/src/utils/logger.cpp b/src/utils/logger.cpp
index 93dd289b..36d43f80 100644
--- a/src/utils/logger.cpp
+++ b/src/utils/logger.cpp
@@ -30,9 +30,6 @@
#include <windows.h>
#endif
-
-namespace tmwserv
-{
namespace utils
{
@@ -290,4 +287,3 @@ Logger::getCurrentTime(void)
} // namespace utils
-} // namespace tmwserv
diff --git a/src/utils/logger.h b/src/utils/logger.h
index d3f0d1a6..e37f33af 100644
--- a/src/utils/logger.h
+++ b/src/utils/logger.h
@@ -30,9 +30,6 @@
#include "singleton.h"
-
-namespace tmwserv
-{
namespace utils
{
@@ -293,8 +290,6 @@ class Logger: public Singleton<Logger>
} // namespace utils
-} // namespace tmwserv
-
// HELPER MACROS
@@ -303,42 +298,42 @@ class Logger: public Singleton<Logger>
do { \
std::ostringstream os; \
os << msg; \
- ::tmwserv::utils::Logger::instance().log(os.str(), atVerbosity); \
+ ::utils::Logger::instance().log(os.str(), atVerbosity); \
} while(0)
#define LOG_DEBUG(msg, atVerbosity) \
do { \
std::ostringstream os; \
os << msg; \
- ::tmwserv::utils::Logger::instance().debug(os.str(), atVerbosity); \
+ ::utils::Logger::instance().debug(os.str(), atVerbosity); \
} while (0)
#define LOG_INFO(msg, atVerbosity) \
do { \
std::ostringstream os; \
os << msg; \
- ::tmwserv::utils::Logger::instance().info(os.str(), atVerbosity); \
+ ::utils::Logger::instance().info(os.str(), atVerbosity); \
} while (0)
#define LOG_WARN(msg, atVerbosity) \
do { \
std::ostringstream os; \
os << msg; \
- ::tmwserv::utils::Logger::instance().warn(os.str(), atVerbosity); \
+ ::utils::Logger::instance().warn(os.str(), atVerbosity); \
} while (0)
#define LOG_ERROR(msg, atVerbosity) \
do { \
std::ostringstream os; \
os << msg; \
- ::tmwserv::utils::Logger::instance().error(os.str(), atVerbosity); \
+ ::utils::Logger::instance().error(os.str(), atVerbosity); \
} while (0)
#define LOG_FATAL(msg, atVerbosity) \
do { \
std::ostringstream os; \
os << msg; \
- ::tmwserv::utils::Logger::instance().fatal(os.str(), atVerbosity); \
+ ::utils::Logger::instance().fatal(os.str(), atVerbosity); \
} while (0)
#endif // _TMWSERV_LOGGER_H_
diff --git a/src/utils/singleton.h b/src/utils/singleton.h
index 4b3589f3..92f6bebe 100644
--- a/src/utils/singleton.h
+++ b/src/utils/singleton.h
@@ -24,9 +24,6 @@
#ifndef _TMWSERV_SINGLETON_H_
#define _TMWSERV_SINGLETON_H_
-
-namespace tmwserv
-{
namespace utils
{
@@ -90,7 +87,5 @@ class Singleton
} // namespace utils
-} // namespace tmwserv
-
#endif // _TMWSERV_SINGLETON_H_
diff --git a/src/utils/stringfilter.cpp b/src/utils/stringfilter.cpp
index cbb075a4..79480838 100644
--- a/src/utils/stringfilter.cpp
+++ b/src/utils/stringfilter.cpp
@@ -27,8 +27,6 @@
#include "../configuration.h"
#include "../defines.h"
-namespace tmwserv
-{
namespace utils
{
@@ -129,4 +127,3 @@ bool StringFilter::findDoubleQuotes(const std::string& text)
}
} // ::utils
-} // ::tmwserv
diff --git a/src/utils/stringfilter.h b/src/utils/stringfilter.h
index e48faa31..5002ca1e 100644
--- a/src/utils/stringfilter.h
+++ b/src/utils/stringfilter.h
@@ -29,8 +29,6 @@
class Configuration;
-namespace tmwserv
-{
namespace utils
{
@@ -95,8 +93,7 @@ class StringFilter
};
} // ::utils
-} // ::tmwserv
-extern tmwserv::utils::StringFilter *stringFilter;
+extern utils::StringFilter *stringFilter;
#endif