- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

# D:/Programmation/Sources/Tensor2/Utils/src/frost_utilsmanager.cpp

Go to the documentation of this file.

    00001 /* ###################################### */
    00002 /* ###     Frost Engine, by Kalith    ### */
    00003 /* ###################################### */
    00004 /*                                        */
    00005
    00006 #include "frost_utilsmanager.h"
    00007 #include "frost_utils_timemanager.h"
    00008
    00009 using namespace std;
    00010
    00011 #ifndef USING_OGRE
    00012 #ifdef WIN32
    00013     #include <sys/timeb.h>
    00014 #else
    00015     #include <sys/time.h>
    00016 #endif
    00017 #endif
    00018
    00019 namespace Frost
    00020 {
    00021     const s_str UtilsManager::CLASS_NAME = "UtilsManager";
    00022
    00023     UtilsManager::UtilsManager()
    00024     {
    00025         pLogFunction_ = nullptr;
    00026     }
    00027
    00028     UtilsManager::~UtilsManager()
    00029     {
    00030     }
    00031
    00032     void UtilsManager::Initialize()
    00033     {
    00034         // Calling srand(time(nullptr)) can result in similar results
    00035         // because time()'s resolution is too low. Here we use a
    00036         // high precision timer.
    00037         srand(TimeManager::GetSingleton()->GetMicroseconds().Get());
    00038
    00039         // In GCC, the first rand() is round(3.25*seed) + 38
    00040         // To get rid of this effect, we just call rand() several times.
    00041         rand(); rand(); rand(); rand();
    00042     }
    00043
    00044     void UtilsManager::SetLogFunction( LogFunction pFunc )
    00045     {
    00046         pLogFunction_ = pFunc;
    00047     }
    00048
    00049     void UtilsManager::Log( const s_str& sMessage, const s_bool& bTimeStamps, const s_uint& uiOffset )
    00050     {
    00051         if (pLogFunction_)
    00052             pLogFunction_(sMessage, bTimeStamps, uiOffset);
    00053     }
    00054
    00055     void UtilsManager::SetLogLevel( const s_uint& uiLevel )
    00056     {
    00057         uiLogLevel_ = uiLevel;
    00058     }
    00059
    00060     const s_uint& UtilsManager::GetLogLevel() const
    00061     {
    00062         return uiLogLevel_;
    00063     }
    00064 }
    00065
    00066
    00067