#ifndef nss_common_H_
#define nss_common_H_

#include <Windows.h>
#include <WinSock2.h>
#include <tchar.h>
#include <string>
#include <sstream>
#include <assert.h>

#include "log4cplus_switch.h"

#if defined(_UNICODE)
#define STR_LITERAL(x) L ## x

inline std::wostream& operator<<(std::wostream& out, const std::string& str)
{
    return out << str.c_str();
}

#else
#define STR_LITERAL(x) x
inline std::ostream& operator<<(std::ostream& out, const std::wstring& wstr)
{
    return out << wstr.c_str();
}

#endif

#if defined(RECORD_LOG) || defined(OUTPUT_LOG)
#define OUTPUT_DEBUG( x ) \
{\
    std::stringstream now;\
    now << "("\
    << GetTickCount() \
    << ")#nsst#[" \
    << __FILE__\
    << ":"\
    << __LINE__\
    << "]("\
    << GetCurrentThreadId()\
    << ")- "\
    << x\
    << std::endl;\
    OutputDebugStringA(now.str().c_str());\
}
#else
#define OUTPUT_DEBUG( x )
#endif

#define NS_1K   (1024)
#define NS_1M   (NS_1K*NS_1K)
#define NS_1G   (NS_1M*NS_1M)

template < class _Type >
class singleton
{
public:
    static _Type* get_instance()
    {
        static _Type instance;
        return &instance;
    }
};

#endif // nss_common_H_