Updated the documentation for some sfml-system classes

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1203 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
LaurentGom 2009-08-14 20:00:42 +00:00
parent ac0881f6a0
commit 351a43f696
26 changed files with 414 additions and 221 deletions

View file

@ -32,16 +32,12 @@
namespace sf
{
////////////////////////////////////////////////////////////
/// Default constructor
////////////////////////////////////////////////////////////
Clock::Clock()
{
Reset();
}
////////////////////////////////////////////////////////////
/// Get the time elapsed since last reset
////////////////////////////////////////////////////////////
float Clock::GetElapsedTime() const
{
@ -49,8 +45,6 @@ float Clock::GetElapsedTime() const
}
////////////////////////////////////////////////////////////
/// Restart the timer
////////////////////////////////////////////////////////////
void Clock::Reset()
{

View file

@ -32,8 +32,6 @@
namespace sf
{
////////////////////////////////////////////////////////////
/// Construct the lock with a target mutex (lock it)
////////////////////////////////////////////////////////////
Lock::Lock(Mutex& mutex) :
myMutex(mutex)
{
@ -41,8 +39,6 @@ myMutex(mutex)
}
////////////////////////////////////////////////////////////
/// Destructor (unlocks the mutex)
////////////////////////////////////////////////////////////
Lock::~Lock()
{

View file

@ -42,16 +42,12 @@
namespace sf
{
////////////////////////////////////////////////////////////
/// Default constructor
////////////////////////////////////////////////////////////
Mutex::Mutex()
{
myMutexImpl = new priv::MutexImpl;
}
////////////////////////////////////////////////////////////
/// Destructor
////////////////////////////////////////////////////////////
Mutex::~Mutex()
{
@ -59,8 +55,6 @@ Mutex::~Mutex()
}
////////////////////////////////////////////////////////////
/// Lock the mutex
////////////////////////////////////////////////////////////
void Mutex::Lock()
{
@ -68,8 +62,6 @@ void Mutex::Lock()
}
////////////////////////////////////////////////////////////
/// Unlock the mutex
////////////////////////////////////////////////////////////
void Mutex::Unlock()
{

View file

@ -30,9 +30,13 @@
#include <cstdlib>
////////////////////////////////////////////////////////////
// Private data
////////////////////////////////////////////////////////////
namespace
{
// Set the random numbers sequence seed with the current system time, so that it is always different
// Initialize the generator's seed with the current system time
// in milliseconds, so that it is always different
unsigned int InitializeSeed()
{
unsigned int seed = static_cast<unsigned int>(sf::priv::Platform::GetSystemTime() * 1000);
@ -48,9 +52,6 @@ namespace
namespace sf
{
////////////////////////////////////////////////////////////
/// Set the seed for the generator. Using a known seed
/// allows you to reproduce the same sequence of random number
////////////////////////////////////////////////////////////
void Randomizer::SetSeed(unsigned int seed)
{
srand(seed);
@ -58,8 +59,6 @@ void Randomizer::SetSeed(unsigned int seed)
}
////////////////////////////////////////////////////////////
/// Get the seed used to generate random numbers the generator.
////////////////////////////////////////////////////////////
unsigned int Randomizer::GetSeed()
{
@ -67,13 +66,10 @@ unsigned int Randomizer::GetSeed()
}
////////////////////////////////////////////////////////////
/// Get a random float number in a given range
////////////////////////////////////////////////////////////
float Randomizer::Random(float begin, float end)
{
// This is not the best algorithm, but it is fast and will be enough in most cases
// (see Google for best approaches)
return static_cast<float>(rand()) / RAND_MAX * (end - begin) + begin;
}
@ -85,7 +81,6 @@ float Randomizer::Random(float begin, float end)
int Randomizer::Random(int begin, int end)
{
// This is not the best algorithm, but it is fast and will be enough in most cases
// (see Google for best approaches)
return rand() % (end - begin + 1) + begin;
}

View file

@ -33,16 +33,12 @@ namespace sf
namespace priv
{
////////////////////////////////////////////////////////////
/// Default constructor
////////////////////////////////////////////////////////////
MutexImpl::MutexImpl()
{
pthread_mutex_init(&myMutex, NULL);
}
////////////////////////////////////////////////////////////
/// Destructor
////////////////////////////////////////////////////////////
MutexImpl::~MutexImpl()
{
@ -50,8 +46,6 @@ MutexImpl::~MutexImpl()
}
////////////////////////////////////////////////////////////
/// Lock the mutex
////////////////////////////////////////////////////////////
void MutexImpl::Lock()
{
@ -59,8 +53,6 @@ void MutexImpl::Lock()
}
////////////////////////////////////////////////////////////
/// Unlock the mutex
////////////////////////////////////////////////////////////
void MutexImpl::Unlock()
{

View file

@ -37,32 +37,32 @@ namespace sf
namespace priv
{
////////////////////////////////////////////////////////////
/// Unix implementation of mutexes
/// \brief Unix implementation of mutexes
////////////////////////////////////////////////////////////
class MutexImpl : NonCopyable
{
public :
////////////////////////////////////////////////////////////
/// Default constructor
/// \brief Default constructor
///
////////////////////////////////////////////////////////////
MutexImpl();
////////////////////////////////////////////////////////////
/// Destructor
/// \brief Destructor
///
////////////////////////////////////////////////////////////
~MutexImpl();
////////////////////////////////////////////////////////////
/// Lock the mutex
/// \brief Lock the mutex
///
////////////////////////////////////////////////////////////
void Lock();
////////////////////////////////////////////////////////////
/// Unlock the mutex
/// \brief Unlock the mutex
///
////////////////////////////////////////////////////////////
void Unlock();

View file

@ -34,8 +34,6 @@ namespace sf
namespace priv
{
////////////////////////////////////////////////////////////
/// Get the current system time
////////////////////////////////////////////////////////////
double Platform::GetSystemTime()
{
timeval time = {0, 0};
@ -45,8 +43,6 @@ double Platform::GetSystemTime()
}
////////////////////////////////////////////////////////////
/// Suspend the execution of the current thread for a specified time
////////////////////////////////////////////////////////////
void Platform::Sleep(float time)
{

View file

@ -37,15 +37,14 @@ namespace sf
namespace priv
{
////////////////////////////////////////////////////////////
/// Unix implementation fo Platform
/// Give access to various global system functions
/// \brief Give access to some system-specific low-level functions
////////////////////////////////////////////////////////////
class Platform
{
public :
////////////////////////////////////////////////////////////
/// Get the current system time
/// \brief Get the current system time
///
/// \return System time, in seconds
///
@ -53,9 +52,9 @@ public :
static double GetSystemTime();
////////////////////////////////////////////////////////////
/// Suspend the execution of the current thread for a specified time
/// \brief Suspend the execution of the current thread for a specified time
///
/// \param time : Time to sleep, in seconds
/// \param time Time to sleep, in seconds
///
////////////////////////////////////////////////////////////
static void Sleep(float time);

View file

@ -35,8 +35,6 @@ namespace sf
namespace priv
{
////////////////////////////////////////////////////////////
/// Default constructor
////////////////////////////////////////////////////////////
ThreadImpl::ThreadImpl(Thread* owner) :
myIsActive(true)
{
@ -47,8 +45,6 @@ myIsActive(true)
}
////////////////////////////////////////////////////////////
/// Wait until the thread finishes
////////////////////////////////////////////////////////////
void ThreadImpl::Wait()
{
@ -57,11 +53,6 @@ void ThreadImpl::Wait()
}
////////////////////////////////////////////////////////////
/// Terminate the thread
/// Terminating a thread with this function is not safe,
/// you should rather try to make the thread function
/// terminate by itself
////////////////////////////////////////////////////////////
void ThreadImpl::Terminate()
{
@ -70,8 +61,6 @@ void ThreadImpl::Terminate()
}
////////////////////////////////////////////////////////////
/// Global entry point for all threads
////////////////////////////////////////////////////////////
void* ThreadImpl::EntryPoint(void* userData)
{

View file

@ -39,31 +39,28 @@ class Thread;
namespace priv
{
////////////////////////////////////////////////////////////
/// Unix implementation of threads
/// \brief Unix implementation of threads
////////////////////////////////////////////////////////////
class ThreadImpl : NonCopyable
{
public :
////////////////////////////////////////////////////////////
/// Default constructor, launch the thread
/// \brief Default constructor, launch the thread
///
/// \param owner : Owner Thread instance to run
/// \param owner The Thread instance to run
///
////////////////////////////////////////////////////////////
ThreadImpl(Thread* owner);
////////////////////////////////////////////////////////////
/// Wait until the thread finishes
/// \brief Wait until the thread finishes
///
////////////////////////////////////////////////////////////
void Wait();
////////////////////////////////////////////////////////////
/// Terminate the thread
/// Terminating a thread with this function is not safe,
/// you should rather try to make the thread function
/// terminate by itself
/// \brief Terminate the thread
///
////////////////////////////////////////////////////////////
void Terminate();
@ -71,11 +68,11 @@ public :
private :
////////////////////////////////////////////////////////////
/// Global entry point for all threads
/// \brief Global entry point for all threads
///
/// \param userData : User-defined data (contains the Thread instance)
/// \param userData User-defined data (contains the Thread instance)
///
/// \return Error code
/// \return Os specific error code
///
////////////////////////////////////////////////////////////
static void* EntryPoint(void* userData);

View file

@ -33,16 +33,12 @@ namespace sf
namespace priv
{
////////////////////////////////////////////////////////////
/// Default constructor -- allocate the storage
////////////////////////////////////////////////////////////
ThreadLocalImpl::ThreadLocalImpl()
{
pthread_key_create(&myKey, NULL);
}
////////////////////////////////////////////////////////////
/// Destructor -- free the storage
////////////////////////////////////////////////////////////
ThreadLocalImpl::~ThreadLocalImpl()
{
@ -50,8 +46,6 @@ ThreadLocalImpl::~ThreadLocalImpl()
}
////////////////////////////////////////////////////////////
/// Set the thread-specific value of the variable
////////////////////////////////////////////////////////////
void ThreadLocalImpl::SetValue(void* value)
{
@ -59,8 +53,6 @@ void ThreadLocalImpl::SetValue(void* value)
}
////////////////////////////////////////////////////////////
/// Retrieve the thread-specific value of the variable
////////////////////////////////////////////////////////////
void* ThreadLocalImpl::GetValue() const
{

View file

@ -37,34 +37,34 @@ namespace sf
namespace priv
{
////////////////////////////////////////////////////////////
/// Unix implementation of thread-local storage
/// \brief Unix implementation of thread-local storage
////////////////////////////////////////////////////////////
class ThreadLocalImpl : NonCopyable
{
public :
////////////////////////////////////////////////////////////
/// Default constructor -- allocate the storage
/// \brief Default constructor -- allocate the storage
///
////////////////////////////////////////////////////////////
ThreadLocalImpl();
////////////////////////////////////////////////////////////
/// Destructor -- free the storage
/// \brief Destructor -- free the storage
///
////////////////////////////////////////////////////////////
~ThreadLocalImpl();
////////////////////////////////////////////////////////////
/// Set the thread-specific value of the variable
/// \brief Set the thread-specific value of the variable
///
/// \param value : Value of the variable for this thread
/// \param value Value of the variable for this thread
///
////////////////////////////////////////////////////////////
void SetValue(void* value);
////////////////////////////////////////////////////////////
/// Retrieve the thread-specific value of the variable
/// \brief Retrieve the thread-specific value of the variable
///
/// \return Value of the variable for this thread
///

View file

@ -33,16 +33,12 @@ namespace sf
namespace priv
{
////////////////////////////////////////////////////////////
/// Default constructor
////////////////////////////////////////////////////////////
MutexImpl::MutexImpl()
{
InitializeCriticalSection(&myMutex);
}
////////////////////////////////////////////////////////////
/// Destructor
////////////////////////////////////////////////////////////
MutexImpl::~MutexImpl()
{
@ -50,8 +46,6 @@ MutexImpl::~MutexImpl()
}
////////////////////////////////////////////////////////////
/// Lock the mutex
////////////////////////////////////////////////////////////
void MutexImpl::Lock()
{
@ -59,8 +53,6 @@ void MutexImpl::Lock()
}
////////////////////////////////////////////////////////////
/// Unlock the mutex
////////////////////////////////////////////////////////////
void MutexImpl::Unlock()
{

View file

@ -37,32 +37,32 @@ namespace sf
namespace priv
{
////////////////////////////////////////////////////////////
/// Windows implementation of mutexes
/// \brief Windows implementation of mutexes
////////////////////////////////////////////////////////////
class MutexImpl : NonCopyable
{
public :
////////////////////////////////////////////////////////////
/// Default constructor
/// \brief Default constructor
///
////////////////////////////////////////////////////////////
MutexImpl();
////////////////////////////////////////////////////////////
/// Destructor
/// \brief Destructor
///
////////////////////////////////////////////////////////////
~MutexImpl();
////////////////////////////////////////////////////////////
/// Lock the mutex
/// \brief Lock the mutex
///
////////////////////////////////////////////////////////////
void Lock();
////////////////////////////////////////////////////////////
/// Unlock the mutex
/// \brief Unlock the mutex
///
////////////////////////////////////////////////////////////
void Unlock();

View file

@ -34,8 +34,6 @@ namespace sf
namespace priv
{
////////////////////////////////////////////////////////////
/// Get the current system time
////////////////////////////////////////////////////////////
double Platform::GetSystemTime()
{
static LARGE_INTEGER Frequency;
@ -57,8 +55,6 @@ double Platform::GetSystemTime()
}
////////////////////////////////////////////////////////////
/// Suspend the execution of the current thread for a specified time
////////////////////////////////////////////////////////////
void Platform::Sleep(float Time)
{

View file

@ -37,15 +37,15 @@ namespace sf
namespace priv
{
////////////////////////////////////////////////////////////
/// Win32 implementation of Platform.
/// Gives access to various global system functions
/// \brief Gives access to some system-specific low-level functions
///
////////////////////////////////////////////////////////////
class Platform
{
public :
////////////////////////////////////////////////////////////
/// Get the current system time
/// \brief Get the current system time
///
/// \return System time, in seconds
///
@ -53,9 +53,9 @@ public :
static double GetSystemTime();
////////////////////////////////////////////////////////////
/// Suspend the execution of the current thread for a specified time
/// \brief Suspend the execution of the current thread for a specified time
///
/// \param time : Time to sleep, in seconds
/// \param time Time to sleep, in seconds
///
////////////////////////////////////////////////////////////
static void Sleep(float time);

View file

@ -36,8 +36,6 @@ namespace sf
namespace priv
{
////////////////////////////////////////////////////////////
/// Default constructor
////////////////////////////////////////////////////////////
ThreadImpl::ThreadImpl(Thread* owner)
{
myThread = reinterpret_cast<HANDLE>(_beginthreadex(NULL, 0, &ThreadImpl::EntryPoint, owner, 0, NULL));
@ -47,8 +45,6 @@ ThreadImpl::ThreadImpl(Thread* owner)
}
////////////////////////////////////////////////////////////
/// Destructor
////////////////////////////////////////////////////////////
ThreadImpl::~ThreadImpl()
{
@ -57,8 +53,6 @@ ThreadImpl::~ThreadImpl()
}
////////////////////////////////////////////////////////////
/// Wait until the thread finishes
////////////////////////////////////////////////////////////
void ThreadImpl::Wait()
{
@ -67,11 +61,6 @@ void ThreadImpl::Wait()
}
////////////////////////////////////////////////////////////
/// Terminate the thread
/// Terminating a thread with this function is not safe,
/// you should rather try to make the thread function
/// terminate by itself
////////////////////////////////////////////////////////////
void ThreadImpl::Terminate()
{
@ -80,8 +69,6 @@ void ThreadImpl::Terminate()
}
////////////////////////////////////////////////////////////
/// Global entry point for all threads
////////////////////////////////////////////////////////////
unsigned int __stdcall ThreadImpl::EntryPoint(void* userData)
{

View file

@ -39,37 +39,34 @@ class Thread;
namespace priv
{
////////////////////////////////////////////////////////////
/// Windows implementation of threads
/// \brief Windows implementation of threads
////////////////////////////////////////////////////////////
class ThreadImpl : NonCopyable
{
public :
////////////////////////////////////////////////////////////
/// Default constructor, launch the thread
/// \brief Default constructor, launch the thread
///
/// \param owner : Owner Thread instance to run
/// \param owner The Thread instance to run
///
////////////////////////////////////////////////////////////
ThreadImpl(Thread* owner);
////////////////////////////////////////////////////////////
/// Destructor
/// \brief Destructor
///
////////////////////////////////////////////////////////////
~ThreadImpl();
////////////////////////////////////////////////////////////
/// Wait until the thread finishes
/// \brief Wait until the thread finishes
///
////////////////////////////////////////////////////////////
void Wait();
////////////////////////////////////////////////////////////
/// Terminate the thread
/// Terminating a thread with this function is not safe,
/// you should rather try to make the thread function
/// terminate by itself
/// \brief Terminate the thread
///
////////////////////////////////////////////////////////////
void Terminate();
@ -77,11 +74,11 @@ public :
private :
////////////////////////////////////////////////////////////
/// Global entry point for all threads
/// \brief Global entry point for all threads
///
/// \param userData : User-defined data (contains the Thread instance)
/// \param userData User-defined data (contains the Thread instance)
///
/// \return Error code
/// \return OS specific error code
///
////////////////////////////////////////////////////////////
static unsigned int __stdcall EntryPoint(void* userData);

View file

@ -33,16 +33,12 @@ namespace sf
namespace priv
{
////////////////////////////////////////////////////////////
/// Default constructor -- allocate the storage
////////////////////////////////////////////////////////////
ThreadLocalImpl::ThreadLocalImpl()
{
myIndex = TlsAlloc();
}
////////////////////////////////////////////////////////////
/// Destructor -- free the storage
////////////////////////////////////////////////////////////
ThreadLocalImpl::~ThreadLocalImpl()
{
@ -50,8 +46,6 @@ ThreadLocalImpl::~ThreadLocalImpl()
}
////////////////////////////////////////////////////////////
/// Set the thread-specific value of the variable
////////////////////////////////////////////////////////////
void ThreadLocalImpl::SetValue(void* value)
{
@ -59,8 +53,6 @@ void ThreadLocalImpl::SetValue(void* value)
}
////////////////////////////////////////////////////////////
/// Retrieve the thread-specific value of the variable
////////////////////////////////////////////////////////////
void* ThreadLocalImpl::GetValue() const
{

View file

@ -37,34 +37,34 @@ namespace sf
namespace priv
{
////////////////////////////////////////////////////////////
/// Windows implementation of thread-local storage
/// \brief Windows implementation of thread-local storage
////////////////////////////////////////////////////////////
class ThreadLocalImpl : NonCopyable
{
public :
////////////////////////////////////////////////////////////
/// Default constructor -- allocate the storage
/// \brief Default constructor -- allocate the storage
///
////////////////////////////////////////////////////////////
ThreadLocalImpl();
////////////////////////////////////////////////////////////
/// Destructor -- free the storage
/// \brief Destructor -- free the storage
///
////////////////////////////////////////////////////////////
~ThreadLocalImpl();
////////////////////////////////////////////////////////////
/// Set the thread-specific value of the variable
/// \brief Set the thread-specific value of the variable
///
/// \param value : Value of the variable for this thread
/// \param value Value of the variable for this thread
///
////////////////////////////////////////////////////////////
void SetValue(void* value);
////////////////////////////////////////////////////////////
/// Retrieve the thread-specific value of the variable
/// \brief Retrieve the thread-specific value of the variable
///
/// \return Value of the variable for this thread
///