clanCore System

Classes

class  clan::BlockAllocated
 Class with operator new/delete overloads for BlockAllocator. More...
 
class  clan::BlockAllocator
 Memory allocator that allocates in blocks. More...
 
class  clan::ConsoleWindow
 Text console window. More...
 
class  clan::DataBuffer
 General purpose data buffer. More...
 
class  clan::DateTime
 Date/Time class. More...
 
class  clan::Exception
 Top-level exception class. More...
 
class  clan::GameTime
 Tracks time elapsed in various forms useful for games. More...
 
class  clan::RegistryKey
 Registry key class. More...
 
class  clan::Service
 Service/daemon class. More...
 
class  clan::System
 General system helper functions. More...
 
class  clan::ThreadLocalStorage
 ThreadLocalStorage class. More...
 
class  clan::ThreadLocalStorageData
 
class  clan::UserData< T >
 
class  clan::UserDataBase
 
class  clan::UserDataOwner
 Helper class to store any shared_ptr as user data on an object. More...
 
class  clan::WorkItem
 Interface for executing work on a worker thread. More...
 
class  clan::WorkQueue
 Thread pool for worker threads. More...
 

Macros

#define cl_tls_variable   __thread
 

Functions

 clan::UserData< T >::UserData (const std::shared_ptr< T > &data)
 
 clan::UserDataOwner::UserDataOwner ()
 
 clan::WorkQueue::WorkQueue (bool serial_queue=false)
 Constructs a work queue. More...
 
virtual clan::ThreadLocalStorageData::~ThreadLocalStorageData ()
 
virtual clan::UserDataBase::~UserDataBase ()
 
 clan::UserDataOwner::~UserDataOwner ()
 
virtual clan::WorkItem::~WorkItem ()
 
 clan::WorkQueue::~WorkQueue ()
 
template<typename T >
std::shared_ptr< T > clan::UserDataOwner::get_data ()
 
int clan::WorkQueue::get_items_queued () const
 Returns the number of items currently queued. More...
 
virtual void clan::WorkItem::process_work ()=0
 Called by a worker thread to process work. More...
 
void clan::WorkQueue::process_work_completed ()
 Process work completed queue. More...
 
void clan::WorkQueue::queue (const std::function< void()> &func)
 Queue some work to be executed on a worker thread. More...
 
void clan::WorkQueue::queue (WorkItem *item)
 Queue some work to be executed on a worker thread. More...
 
template<typename T >
void clan::UserDataOwner::set_data (const std::shared_ptr< T > &data)
 
virtual void clan::WorkItem::work_completed ()
 Called by the WorkQueue thread to complete the work. More...
 
void clan::WorkQueue::work_completed (const std::function< void()> &func)
 Queue some work to be executed on the main WorkQueue thread. More...
 

Variables

std::shared_ptr< T > clan::UserData< T >::data
 
const float clan::PI = 3.14159274101257f
 
const double clan::PI_D = 3.141592653589793115998
 
const float clan::PI_F = 3.14159274101257f
 

Friends

class clan::ThreadLocalStorage::ThreadLocalStorage_Instance
 

Construction

 clan::BlockAllocator::BlockAllocator ()
 Block Allocator constructor. More...
 

Operations

void * clan::BlockAllocator::allocate (int size)
 Allocate memory (See note on this class for the allocation method) More...
 
void clan::BlockAllocator::free ()
 Free the allocated memory. More...
 

Operations

void * clan::BlockAllocated::operator new (size_t size, BlockAllocator *allocator)
 
void clan::BlockAllocated::operator delete (void *data, size_t size)
 
void clan::BlockAllocated::operator delete (void *data, BlockAllocator *allocator)
 

Construction

 clan::ConsoleWindow::ConsoleWindow (const std::string &title, int width=80, int height=25)
 Console Window constructor. More...
 
 clan::ConsoleWindow::~ConsoleWindow ()
 Console Window destructor. More...
 

Operations

void clan::ConsoleWindow::wait_for_key ()
 Waits until user hits a key. More...
 
void clan::ConsoleWindow::display_close_message ()
 Displays 'press any key to close this console window',. More...
 

Construction

 clan::DataBuffer::DataBuffer ()
 Constructs a data buffer of 0 size. More...
 
 clan::DataBuffer::DataBuffer (unsigned int size)
 
 clan::DataBuffer::DataBuffer (const void *data, unsigned int size)
 
 clan::DataBuffer::DataBuffer (const DataBuffer &data, unsigned int pos, unsigned int size)
 
 clan::DataBuffer::~DataBuffer ()
 

Attributes

char * clan::DataBuffer::get_data ()
 Returns a pointer to the data. More...
 
const char * clan::DataBuffer::get_data () const
 
template<typename Type >
Type * clan::DataBuffer::get_data ()
 
template<typename Type >
const Type * clan::DataBuffer::get_data () const
 
unsigned int clan::DataBuffer::get_size () const
 Returns the size of the data. More...
 
unsigned int clan::DataBuffer::get_capacity () const
 Returns the capacity of the data buffer object. More...
 
char & clan::DataBuffer::operator[] (int i)
 Returns a char in the buffer. More...
 
const char & clan::DataBuffer::operator[] (int i) const
 
char & clan::DataBuffer::operator[] (unsigned int i)
 
const char & clan::DataBuffer::operator[] (unsigned int i) const
 
bool clan::DataBuffer::is_null () const
 Returns true if the buffer is 0 in size. More...
 

Operations

DataBufferclan::DataBuffer::operator= (const DataBuffer &copy)
 
void clan::DataBuffer::set_size (unsigned int size)
 Resize the buffer. More...
 
void clan::DataBuffer::set_capacity (unsigned int capacity)
 Preallocate enough memory. More...
 

Construction

enum  clan::DateTime::TimeZone { clan::DateTime::local_timezone, clan::DateTime::utc_timezone }
 
 clan::DateTime::DateTime ()
 Constructs a date/time object. More...
 
 clan::DateTime::DateTime (int year, int month, int day, int hour=0, int minute=0, int seconds=0, int nanoseconds=0, TimeZone timezone=utc_timezone)
 
 clan::DateTime::~DateTime ()
 
static DateTime clan::DateTime::get_current_local_time ()
 Get current system time in local time zone. More...
 
static DateTime clan::DateTime::get_current_utc_time ()
 Get current system time in UTC. More...
 
static DateTime clan::DateTime::get_local_time_from_ticks (int64_t ticks)
 Converts a time tick value (number of 100-nanosecond intervals since January 1, 1601 UTC) to a date time in the local time zone. More...
 
static DateTime clan::DateTime::get_utc_time_from_ticks (int64_t ticks)
 Converts a time tick value (number of 100-nanosecond intervals since January 1, 1601 UTC) to a date time in UTC. More...
 
static DateTime clan::DateTime::from_short_date_string (const std::string &value)
 

Attributes

bool clan::DateTime::is_null () const
 
unsigned short clan::DateTime::get_year () const
 
unsigned char clan::DateTime::get_month () const
 Returns the month number in range 1-12. More...
 
unsigned char clan::DateTime::get_day () const
 
unsigned char clan::DateTime::get_hour () const
 
unsigned char clan::DateTime::get_minutes () const
 
unsigned char clan::DateTime::get_seconds () const
 
unsigned int clan::DateTime::get_nanoseconds () const
 
TimeZone clan::DateTime::get_timezone () const
 
unsigned char clan::DateTime::get_week () const
 Returns the ISO 8601 week number of the date. More...
 
int clan::DateTime::get_difference_in_days (const DateTime &other) const
 Returns the difference in days between two dates. This function is only accurate for the next few millenniums. More...
 
unsigned int clan::DateTime::get_day_of_week () const
 Get the day of the week. More...
 
static int clan::DateTime::get_days_in_month (int month, int year)
 Returns the number of days in the given month. More...
 

Operations

void clan::DateTime::set_null ()
 
void clan::DateTime::set_date (int year, int month, int day, int hour=0, int minute=0, int seconds=0, int nanoseconds=0, TimeZone timezone=utc_timezone)
 
void clan::DateTime::set_year (int year)
 
void clan::DateTime::set_month (int month)
 
void clan::DateTime::set_day (int day)
 
void clan::DateTime::set_hour (int hour)
 
void clan::DateTime::set_minutes (int minutes)
 
void clan::DateTime::set_seconds (int seconds)
 
void clan::DateTime::set_nanoseconds (int nanoseconds)
 
void clan::DateTime::set_timezone (TimeZone timezone)
 
DateTimeclan::DateTime::add_years (int years)
 
DateTimeclan::DateTime::add_days (int days)
 
DateTimeclan::DateTime::add_months (int months)
 
DateTime clan::DateTime::to_utc () const
 
DateTime clan::DateTime::to_local () const
 
int64_t clan::DateTime::to_ticks () const
 Converts the date to the number of 100-nanosecond intervals since January 1, 1601 UTC. More...
 
std::string clan::DateTime::to_long_date_string () const
 Mon Mar 3 2007. More...
 
std::string clan::DateTime::to_short_date_string () const
 yyyy-mm-dd More...
 
std::string clan::DateTime::to_short_datetime_string () const
 yyyy-mm-dd hh:mm:ss More...
 
std::string clan::DateTime::to_long_time_string () const
 hh:mm:ss More...
 
std::string clan::DateTime::to_short_time_string () const
 hh:mm More...
 
std::string clan::DateTime::to_string () const
 Mon Feb 3 12:32:54 2008. More...
 
bool clan::DateTime::operator< (const DateTime &other) const
 
bool clan::DateTime::operator<= (const DateTime &other) const
 
bool clan::DateTime::operator> (const DateTime &other) const
 
bool clan::DateTime::operator>= (const DateTime &other) const
 
bool clan::DateTime::operator== (const DateTime &other) const
 
bool clan::DateTime::operator!= (const DateTime &other) const
 

Construction

 clan::Exception::Exception (const std::string &message)
 Constructs an exception object. More...
 
virtual clan::Exception::~Exception () throw ()
 Destructs an exception object. More...
 

Attributes

std::string clan::Exception::message
 Description of exception. More...
 
virtual const char * clan::Exception::what () const override throw ()
 Returns description of exception. More...
 

Operations

std::vector< std::string > clan::Exception::get_stack_trace () const
 Returns the call stack present when the exception object was created. More...
 
std::string clan::Exception::get_message_and_stack_trace () const
 Returns the message and call stack present when the exception object was created, formatted using newlines. More...
 

Construction

 clan::GameTime::GameTime (int ticks_per_second=20, int max_updates_per_second=0)
 GameTime constructor. More...
 

Attributes

float clan::GameTime::get_time_elapsed () const
 Returns the time elapsed in seconds since last update. More...
 
int clan::GameTime::get_time_elapsed_ms () const
 Returns the time elapsed in seconds since last update in milliseconds. More...
 
int clan::GameTime::get_ticks_elapsed () const
 Returns the number of ticks that elapsed since last update. More...
 
float clan::GameTime::get_tick_time_elapsed () const
 Returns the time elapsed per tick. More...
 
int clan::GameTime::get_tick_time_elapsed_ms () const
 Returns the time elapsed per tick in milliseconds. More...
 
float clan::GameTime::get_tick_interpolation_time () const
 Returns the current time between ticks as a normalized number. More...
 
float clan::GameTime::get_updates_per_second () const
 Returns the number of updates that occurred every second (aka fps, frames per second) More...
 
float clan::GameTime::get_current_time () const
 Returns the number of seconds since this class was reset() More...
 
uint64_t clan::GameTime::get_current_time_microseconds () const
 Returns the number of microseconds since this class was reset() More...
 
uint64_t clan::GameTime::get_current_time_ms () const
 Returns the number of milliseconds since this class was reset() More...
 

Operations

void clan::GameTime::update ()
 Updates time data for the frame to be rendered. More...
 
void clan::GameTime::reset ()
 Resets the timer. More...
 

Construction

enum  clan::RegistryKey::PredefinedKey {
  clan::RegistryKey::key_classes_root, clan::RegistryKey::key_current_config, clan::RegistryKey::key_current_user, clan::RegistryKey::key_local_machine,
  clan::RegistryKey::key_users
}
 
enum  clan::RegistryKey::CreateFlags { clan::RegistryKey::create_always = 0, clan::RegistryKey::create_new = 1, clan::RegistryKey::create_volatile = 2 }
 
 clan::RegistryKey::RegistryKey ()
 
 clan::RegistryKey::RegistryKey (PredefinedKey key, const std::string &subkey, unsigned int access_rights=KEY_ALL_ACCESS, unsigned int create_flags=create_always)
 
 clan::RegistryKey::RegistryKey (HKEY key)
 
 clan::RegistryKey::~RegistryKey ()
 

Attributes

bool clan::RegistryKey::is_null () const
 Returns true if this object is invalid. More...
 
void clan::RegistryKey::throw_if_null () const
 Throw an exception if this object is invalid. More...
 
HKEY clan::RegistryKey::get_key () const
 
std::vector< std::string > clan::RegistryKey::get_subkey_names () const
 
std::vector< std::string > clan::RegistryKey::get_value_names () const
 
int clan::RegistryKey::get_value_int (const std::string &name, int default_value=0) const
 
DataBuffer clan::RegistryKey::get_value_binary (const std::string &name, const DataBuffer &default_value=DataBuffer()) const
 
std::string clan::RegistryKey::get_value_string (const std::string &name, const std::string &default_value=std::string()) const
 
std::vector< std::string > clan::RegistryKey::get_value_multi_string (const std::string &name, const std::vector< std::string > &default_value=std::vector< std::string >()) const
 

Operations

RegistryKey clan::RegistryKey::open_key (const std::string &subkey, unsigned int access_rights=KEY_ALL_ACCESS)
 
RegistryKey clan::RegistryKey::create_key (const std::string &subkey, unsigned int access_rights=KEY_ALL_ACCESS, CreateFlags create_flags=create_always)
 
void clan::RegistryKey::delete_key (const std::string &subkey, bool recursive)
 
static void clan::RegistryKey::delete_key (PredefinedKey key, const std::string &subkey, bool recursive)
 
void clan::RegistryKey::set_value_int (const std::string &name, int value)
 
void clan::RegistryKey::set_value_binary (const std::string &name, const DataBuffer &value)
 
void clan::RegistryKey::set_value_string (const std::string &name, const std::string &value)
 
void clan::RegistryKey::delete_value (const std::string &name)
 

Construction

 clan::Service::Service (const std::string &service_name)
 Constructs a service object. More...
 
 clan::Service::~Service ()
 

Attributes

const std::string & clan::Service::get_service_name () const
 Returns the service name. More...
 

Operations

int clan::Service::main (int argc, char **argv)
 Process command line and run service. More...
 
virtual void clan::Service::service_start (std::vector< std::string > &args)=0
 Called when the service is asked to start. More...
 
virtual void clan::Service::service_stop ()=0
 Called when the service is asked to stop. More...
 
virtual void clan::Service::service_reload ()=0
 Called when the service is asked to reload its configuration. More...
 

Implementation

class clan::Service::Service_Impl
 

Attributes

enum  clan::System::CPU_ExtensionX86 {
  clan::System::mmx, clan::System::mmx_ex, clan::System::_3d_now, clan::System::_3d_now_ex,
  clan::System::sse, clan::System::sse2, clan::System::sse3, clan::System::ssse3,
  clan::System::sse4_a, clan::System::sse4_1, clan::System::sse4_2, clan::System::xop,
  clan::System::avx, clan::System::aes, clan::System::fma3, clan::System::fma4
}
 
enum  clan::System::CPU_ExtensionPPC { clan::System::altivec }
 
static uint64_t clan::System::get_time ()
 Get the current time (since system boot), in milliseconds. More...
 
static uint64_t clan::System::get_microseconds ()
 Get the current time microseconds. More...
 
static bool clan::System::detect_cpu_extension (CPU_ExtensionX86 ext)
 
static bool clan::System::detect_cpu_extension (CPU_ExtensionPPC ext)
 
static int clan::System::get_num_cores ()
 Return the number of CPU cores. More...
 

Operations

static void * clan::System::aligned_alloc (size_t size, size_t alignment=16)
 Allocates aligned memory. More...
 
static void clan::System::aligned_free (void *ptr)
 Frees aligned memory. More...
 
static int clan::System::capture_stack_trace (int frames_to_skip, int max_frames, void **out_frames, unsigned int *out_hash=nullptr)
 Captures a stack back trace by walking up the stack and recording the information for each frame. More...
 
static std::vector< std::string > clan::System::get_stack_frames_text (void **frames, int num_frames)
 Returns the function names and lines for the specified stack frame addresses. More...
 
static void clan::System::sleep (int millis)
 Sleep for 'millis' milliseconds. More...
 
static void clan::System::pause (int millis)
 Pause for 'millis' milliseconds. More...
 
static std::string clan::System::get_exe_path ()
 Returns the full dirname of the executable that started this. More...
 

Construction

 clan::ThreadLocalStorage::ThreadLocalStorage ()
 Constructs a Thread Local Storage object. More...
 
 clan::ThreadLocalStorage::~ThreadLocalStorage ()
 

Attributes

static std::shared_ptr< ThreadLocalStorageDataclan::ThreadLocalStorage::get_variable (const std::string &name)
 Get a variable. More...
 

Operations

static void clan::ThreadLocalStorage::set_variable (const std::string &name, std::shared_ptr< ThreadLocalStorageData > ptr)
 Set a variable. More...
 

Detailed Description

Macro Definition Documentation

◆ cl_tls_variable

#define cl_tls_variable   __thread

Enumeration Type Documentation

◆ CPU_ExtensionPPC

Enumerator
altivec 

◆ CPU_ExtensionX86

Enumerator
mmx 
mmx_ex 
_3d_now 
_3d_now_ex 
sse 
sse2 
sse3 
ssse3 
sse4_a 
sse4_1 
sse4_2 
xop 
avx 
aes 
fma3 
fma4 

◆ CreateFlags

Enumerator
create_always 
create_new 
create_volatile 

◆ PredefinedKey

Enumerator
key_classes_root 
key_current_config 
key_current_user 
key_local_machine 
key_users 

◆ TimeZone

Enumerator
local_timezone 
utc_timezone 

Function Documentation

◆ BlockAllocator()

clan::BlockAllocator::BlockAllocator ( )

Block Allocator constructor.

◆ ConsoleWindow()

clan::ConsoleWindow::ConsoleWindow ( const std::string &  title,
int  width = 80,
int  height = 25 
)

Console Window constructor.

Parameters
titleWindow title of console window.
widthColumns in console window.
heightRows in console window.

◆ DataBuffer() [1/4]

clan::DataBuffer::DataBuffer ( )

Constructs a data buffer of 0 size.

◆ DataBuffer() [2/4]

clan::DataBuffer::DataBuffer ( const DataBuffer data,
unsigned int  pos,
unsigned int  size 
)

◆ DataBuffer() [3/4]

clan::DataBuffer::DataBuffer ( const void *  data,
unsigned int  size 
)

◆ DataBuffer() [4/4]

clan::DataBuffer::DataBuffer ( unsigned int  size)

◆ DateTime() [1/2]

clan::DateTime::DateTime ( )

Constructs a date/time object.

◆ DateTime() [2/2]

clan::DateTime::DateTime ( int  year,
int  month,
int  day,
int  hour = 0,
int  minute = 0,
int  seconds = 0,
int  nanoseconds = 0,
TimeZone  timezone = utc_timezone 
)

◆ Exception()

clan::Exception::Exception ( const std::string &  message)

Constructs an exception object.

◆ GameTime()

clan::GameTime::GameTime ( int  ticks_per_second = 20,
int  max_updates_per_second = 0 
)

GameTime constructor.

Parameters
ticks_per_second= Number of ticks per second
max_updates_per_second= Maximum number of updates per second (aka FPS, frames per second). 0 = Unlimited

◆ RegistryKey() [1/3]

clan::RegistryKey::RegistryKey ( )

◆ RegistryKey() [2/3]

clan::RegistryKey::RegistryKey ( HKEY  key)

◆ RegistryKey() [3/3]

clan::RegistryKey::RegistryKey ( PredefinedKey  key,
const std::string &  subkey,
unsigned int  access_rights = KEY_ALL_ACCESS,
unsigned int  create_flags = create_always 
)

◆ Service()

clan::Service::Service ( const std::string &  service_name)

Constructs a service object.

◆ ThreadLocalStorage()

clan::ThreadLocalStorage::ThreadLocalStorage ( )

Constructs a Thread Local Storage object.

◆ UserData()

template<typename T >
clan::UserData< T >::UserData ( const std::shared_ptr< T > &  data)
inline

◆ UserDataOwner()

clan::UserDataOwner::UserDataOwner ( )
inline

◆ WorkQueue()

clan::WorkQueue::WorkQueue ( bool  serial_queue = false)

Constructs a work queue.

Parameters
serial_queueIf true, executes items in the order they are queued, one at a time

◆ ~ConsoleWindow()

clan::ConsoleWindow::~ConsoleWindow ( )

Console Window destructor.

◆ ~DataBuffer()

clan::DataBuffer::~DataBuffer ( )

◆ ~DateTime()

clan::DateTime::~DateTime ( )

◆ ~Exception()

virtual clan::Exception::~Exception ( )
throw (
)
inlinevirtual

Destructs an exception object.

◆ ~RegistryKey()

clan::RegistryKey::~RegistryKey ( )

◆ ~Service()

clan::Service::~Service ( )

◆ ~ThreadLocalStorage()

clan::ThreadLocalStorage::~ThreadLocalStorage ( )

◆ ~ThreadLocalStorageData()

virtual clan::ThreadLocalStorageData::~ThreadLocalStorageData ( )
inlinevirtual

◆ ~UserDataBase()

virtual clan::UserDataBase::~UserDataBase ( )
inlinevirtual

◆ ~UserDataOwner()

clan::UserDataOwner::~UserDataOwner ( )
inline

◆ ~WorkItem()

virtual clan::WorkItem::~WorkItem ( )
inlinevirtual

◆ ~WorkQueue()

clan::WorkQueue::~WorkQueue ( )

◆ add_days()

DateTime& clan::DateTime::add_days ( int  days)

◆ add_months()

DateTime& clan::DateTime::add_months ( int  months)

◆ add_years()

DateTime& clan::DateTime::add_years ( int  years)

◆ aligned_alloc()

static void* clan::System::aligned_alloc ( size_t  size,
size_t  alignment = 16 
)
static

Allocates aligned memory.

◆ aligned_free()

static void clan::System::aligned_free ( void *  ptr)
static

Frees aligned memory.

◆ allocate()

void* clan::BlockAllocator::allocate ( int  size)

Allocate memory (See note on this class for the allocation method)

param: size = Size to allocate (in bytes)

Returns
The memory

◆ capture_stack_trace()

static int clan::System::capture_stack_trace ( int  frames_to_skip,
int  max_frames,
void **  out_frames,
unsigned int *  out_hash = nullptr 
)
static

Captures a stack back trace by walking up the stack and recording the information for each frame.

◆ create_key()

RegistryKey clan::RegistryKey::create_key ( const std::string &  subkey,
unsigned int  access_rights = KEY_ALL_ACCESS,
CreateFlags  create_flags = create_always 
)

◆ delete_key() [1/2]

void clan::RegistryKey::delete_key ( const std::string &  subkey,
bool  recursive 
)

◆ delete_key() [2/2]

static void clan::RegistryKey::delete_key ( PredefinedKey  key,
const std::string &  subkey,
bool  recursive 
)
static

◆ delete_value()

void clan::RegistryKey::delete_value ( const std::string &  name)

◆ detect_cpu_extension() [1/2]

static bool clan::System::detect_cpu_extension ( CPU_ExtensionPPC  ext)
static

◆ detect_cpu_extension() [2/2]

static bool clan::System::detect_cpu_extension ( CPU_ExtensionX86  ext)
static

◆ display_close_message()

void clan::ConsoleWindow::display_close_message ( )

Displays 'press any key to close this console window',.

and waits until user hits a key.

This function does not do anything on Linux.

◆ free()

void clan::BlockAllocator::free ( )

Free the allocated memory.

If required, use delete_obj() to call the destructor before using this function

◆ from_short_date_string()

static DateTime clan::DateTime::from_short_date_string ( const std::string &  value)
static

◆ get_capacity()

unsigned int clan::DataBuffer::get_capacity ( ) const

Returns the capacity of the data buffer object.

◆ get_current_local_time()

static DateTime clan::DateTime::get_current_local_time ( )
static

Get current system time in local time zone.

◆ get_current_time()

float clan::GameTime::get_current_time ( ) const

Returns the number of seconds since this class was reset()

◆ get_current_time_microseconds()

uint64_t clan::GameTime::get_current_time_microseconds ( ) const

Returns the number of microseconds since this class was reset()

◆ get_current_time_ms()

uint64_t clan::GameTime::get_current_time_ms ( ) const

Returns the number of milliseconds since this class was reset()

◆ get_current_utc_time()

static DateTime clan::DateTime::get_current_utc_time ( )
static

Get current system time in UTC.

◆ get_data() [1/5]

char* clan::DataBuffer::get_data ( )

Returns a pointer to the data.

◆ get_data() [2/5]

template<typename Type >
Type* clan::DataBuffer::get_data ( )
inline

◆ get_data() [3/5]

template<typename T >
std::shared_ptr<T> clan::UserDataOwner::get_data ( )
inline

References clan::d.

Referenced by clan::ResourceManager::get_cache().

◆ get_data() [4/5]

const char* clan::DataBuffer::get_data ( ) const

◆ get_data() [5/5]

template<typename Type >
const Type* clan::DataBuffer::get_data ( ) const
inline

◆ get_day()

unsigned char clan::DateTime::get_day ( ) const

◆ get_day_of_week()

unsigned int clan::DateTime::get_day_of_week ( ) const

Get the day of the week.

Returns
0 = Sunday ... 6 = Saturday

◆ get_days_in_month()

static int clan::DateTime::get_days_in_month ( int  month,
int  year 
)
static

Returns the number of days in the given month.

Returns
number of days: 28-31.

◆ get_difference_in_days()

int clan::DateTime::get_difference_in_days ( const DateTime other) const

Returns the difference in days between two dates. This function is only accurate for the next few millenniums.

Returns
Number of days between dates. Returns a negative value if 'other' is before 'this'.

◆ get_exe_path()

static std::string clan::System::get_exe_path ( )
static

Returns the full dirname of the executable that started this.

process (aka argv[0])

This is necessary since when programms are started from the PATH there is no clean and simple way to figure out the location of the data files, thus information is read from /proc/self/exe under GNU/Linux and from GetModuleFileName() on Win32.

Returns
full dirname of the executable, trailing slash is included

◆ get_hour()

unsigned char clan::DateTime::get_hour ( ) const

◆ get_items_queued()

int clan::WorkQueue::get_items_queued ( ) const

Returns the number of items currently queued.

◆ get_key()

HKEY clan::RegistryKey::get_key ( ) const

◆ get_local_time_from_ticks()

static DateTime clan::DateTime::get_local_time_from_ticks ( int64_t  ticks)
static

Converts a time tick value (number of 100-nanosecond intervals since January 1, 1601 UTC) to a date time in the local time zone.

◆ get_message_and_stack_trace()

std::string clan::Exception::get_message_and_stack_trace ( ) const

Returns the message and call stack present when the exception object was created, formatted using newlines.

On Linux, to obtain function names, remember to link with the -rdynamic flag

◆ get_microseconds()

static uint64_t clan::System::get_microseconds ( )
static

Get the current time microseconds.

◆ get_minutes()

unsigned char clan::DateTime::get_minutes ( ) const

◆ get_month()

unsigned char clan::DateTime::get_month ( ) const

Returns the month number in range 1-12.

Returns
1 = Jan ... 12 = December

◆ get_nanoseconds()

unsigned int clan::DateTime::get_nanoseconds ( ) const

◆ get_num_cores()

static int clan::System::get_num_cores ( )
static

Return the number of CPU cores.

◆ get_seconds()

unsigned char clan::DateTime::get_seconds ( ) const

◆ get_service_name()

const std::string& clan::Service::get_service_name ( ) const

Returns the service name.

◆ get_size()

unsigned int clan::DataBuffer::get_size ( ) const

Returns the size of the data.

◆ get_stack_frames_text()

static std::vector<std::string> clan::System::get_stack_frames_text ( void **  frames,
int  num_frames 
)
static

Returns the function names and lines for the specified stack frame addresses.

On Linux, to obtain function names, remember to link with the -rdynamic flag

◆ get_stack_trace()

std::vector<std::string> clan::Exception::get_stack_trace ( ) const

Returns the call stack present when the exception object was created.

On Linux, to obtain function names, remember to link with the -rdynamic flag

◆ get_subkey_names()

std::vector<std::string> clan::RegistryKey::get_subkey_names ( ) const

◆ get_tick_interpolation_time()

float clan::GameTime::get_tick_interpolation_time ( ) const

Returns the current time between ticks as a normalized number.

If the current time is half-way between two tick updates this function returns 0.5, at the start of a tick its 0.0, and at the end its 1.0.

◆ get_tick_time_elapsed()

float clan::GameTime::get_tick_time_elapsed ( ) const

Returns the time elapsed per tick.

◆ get_tick_time_elapsed_ms()

int clan::GameTime::get_tick_time_elapsed_ms ( ) const

Returns the time elapsed per tick in milliseconds.

◆ get_ticks_elapsed()

int clan::GameTime::get_ticks_elapsed ( ) const

Returns the number of ticks that elapsed since last update.

◆ get_time()

static uint64_t clan::System::get_time ( )
static

Get the current time (since system boot), in milliseconds.

◆ get_time_elapsed()

float clan::GameTime::get_time_elapsed ( ) const

Returns the time elapsed in seconds since last update.

◆ get_time_elapsed_ms()

int clan::GameTime::get_time_elapsed_ms ( ) const

Returns the time elapsed in seconds since last update in milliseconds.

◆ get_timezone()

TimeZone clan::DateTime::get_timezone ( ) const

◆ get_updates_per_second()

float clan::GameTime::get_updates_per_second ( ) const

Returns the number of updates that occurred every second (aka fps, frames per second)

◆ get_utc_time_from_ticks()

static DateTime clan::DateTime::get_utc_time_from_ticks ( int64_t  ticks)
static

Converts a time tick value (number of 100-nanosecond intervals since January 1, 1601 UTC) to a date time in UTC.

◆ get_value_binary()

DataBuffer clan::RegistryKey::get_value_binary ( const std::string &  name,
const DataBuffer default_value = DataBuffer() 
) const

◆ get_value_int()

int clan::RegistryKey::get_value_int ( const std::string &  name,
int  default_value = 0 
) const

◆ get_value_multi_string()

std::vector<std::string> clan::RegistryKey::get_value_multi_string ( const std::string &  name,
const std::vector< std::string > &  default_value = std::vector< std::string >() 
) const

◆ get_value_names()

std::vector<std::string> clan::RegistryKey::get_value_names ( ) const

◆ get_value_string()

std::string clan::RegistryKey::get_value_string ( const std::string &  name,
const std::string &  default_value = std::string() 
) const

◆ get_variable()

static std::shared_ptr<ThreadLocalStorageData> clan::ThreadLocalStorage::get_variable ( const std::string &  name)
static

Get a variable.

◆ get_week()

unsigned char clan::DateTime::get_week ( ) const

Returns the ISO 8601 week number of the date.

Returns
Week number: 1-53.

◆ get_year()

unsigned short clan::DateTime::get_year ( ) const

◆ is_null() [1/3]

bool clan::DateTime::is_null ( ) const

◆ is_null() [2/3]

bool clan::DataBuffer::is_null ( ) const

Returns true if the buffer is 0 in size.

◆ is_null() [3/3]

bool clan::RegistryKey::is_null ( ) const
inline

Returns true if this object is invalid.

◆ main()

int clan::Service::main ( int  argc,
char **  argv 
)

Process command line and run service.

◆ open_key()

RegistryKey clan::RegistryKey::open_key ( const std::string &  subkey,
unsigned int  access_rights = KEY_ALL_ACCESS 
)

◆ operator delete() [1/2]

void clan::BlockAllocated::operator delete ( void *  data,
BlockAllocator allocator 
)

◆ operator delete() [2/2]

void clan::BlockAllocated::operator delete ( void *  data,
size_t  size 
)

◆ operator new()

void* clan::BlockAllocated::operator new ( size_t  size,
BlockAllocator allocator 
)

◆ operator!=()

bool clan::DateTime::operator!= ( const DateTime other) const

◆ operator<()

bool clan::DateTime::operator< ( const DateTime other) const

◆ operator<=()

bool clan::DateTime::operator<= ( const DateTime other) const

◆ operator=()

DataBuffer& clan::DataBuffer::operator= ( const DataBuffer copy)

◆ operator==()

bool clan::DateTime::operator== ( const DateTime other) const

◆ operator>()

bool clan::DateTime::operator> ( const DateTime other) const

◆ operator>=()

bool clan::DateTime::operator>= ( const DateTime other) const

◆ operator[]() [1/4]

char& clan::DataBuffer::operator[] ( int  i)

Returns a char in the buffer.

◆ operator[]() [2/4]

const char& clan::DataBuffer::operator[] ( int  i) const

◆ operator[]() [3/4]

char& clan::DataBuffer::operator[] ( unsigned int  i)

◆ operator[]() [4/4]

const char& clan::DataBuffer::operator[] ( unsigned int  i) const

◆ pause()

static void clan::System::pause ( int  millis)
static

Pause for 'millis' milliseconds.

This function acts as sleep, but the function "may" perform a spinlock on some operating systems to give a more accurate pause. This may have a side effect of causing 100% cpu usage. If you do not require an accurate pause, use sleep instead.

◆ process_work()

virtual void clan::WorkItem::process_work ( )
pure virtual

Called by a worker thread to process work.

◆ process_work_completed()

void clan::WorkQueue::process_work_completed ( )

Process work completed queue.

Needs to be called on the main WorkQueue thread periodically to finish queued work

◆ queue() [1/2]

void clan::WorkQueue::queue ( const std::function< void()> &  func)

Queue some work to be executed on a worker thread.

◆ queue() [2/2]

void clan::WorkQueue::queue ( WorkItem item)

Queue some work to be executed on a worker thread.

Transfers ownership of the item queued. WorkQueue will delete the item.

◆ reset()

void clan::GameTime::reset ( )

Resets the timer.

◆ service_reload()

virtual void clan::Service::service_reload ( )
protectedpure virtual

Called when the service is asked to reload its configuration.

◆ service_start()

virtual void clan::Service::service_start ( std::vector< std::string > &  args)
protectedpure virtual

Called when the service is asked to start.

◆ service_stop()

virtual void clan::Service::service_stop ( )
protectedpure virtual

Called when the service is asked to stop.

◆ set_capacity()

void clan::DataBuffer::set_capacity ( unsigned int  capacity)

Preallocate enough memory.

◆ set_data()

template<typename T >
void clan::UserDataOwner::set_data ( const std::shared_ptr< T > &  data)
inline

◆ set_date()

void clan::DateTime::set_date ( int  year,
int  month,
int  day,
int  hour = 0,
int  minute = 0,
int  seconds = 0,
int  nanoseconds = 0,
TimeZone  timezone = utc_timezone 
)

◆ set_day()

void clan::DateTime::set_day ( int  day)

◆ set_hour()

void clan::DateTime::set_hour ( int  hour)

◆ set_minutes()

void clan::DateTime::set_minutes ( int  minutes)

◆ set_month()

void clan::DateTime::set_month ( int  month)

◆ set_nanoseconds()

void clan::DateTime::set_nanoseconds ( int  nanoseconds)

◆ set_null()

void clan::DateTime::set_null ( )

◆ set_seconds()

void clan::DateTime::set_seconds ( int  seconds)

◆ set_size()

void clan::DataBuffer::set_size ( unsigned int  size)

Resize the buffer.

◆ set_timezone()

void clan::DateTime::set_timezone ( TimeZone  timezone)

◆ set_value_binary()

void clan::RegistryKey::set_value_binary ( const std::string &  name,
const DataBuffer value 
)

◆ set_value_int()

void clan::RegistryKey::set_value_int ( const std::string &  name,
int  value 
)

◆ set_value_string()

void clan::RegistryKey::set_value_string ( const std::string &  name,
const std::string &  value 
)

◆ set_variable()

static void clan::ThreadLocalStorage::set_variable ( const std::string &  name,
std::shared_ptr< ThreadLocalStorageData ptr 
)
static

Set a variable.

◆ set_year()

void clan::DateTime::set_year ( int  year)

◆ sleep()

static void clan::System::sleep ( int  millis)
static

Sleep for 'millis' milliseconds.

It is possible for this function to sleep for more than millis, depending on the OS scheduler. If you require a more accurate sleep, consider pause.

◆ throw_if_null()

void clan::RegistryKey::throw_if_null ( ) const

Throw an exception if this object is invalid.

◆ to_local()

DateTime clan::DateTime::to_local ( ) const

◆ to_long_date_string()

std::string clan::DateTime::to_long_date_string ( ) const

Mon Mar 3 2007.

◆ to_long_time_string()

std::string clan::DateTime::to_long_time_string ( ) const

hh:mm:ss

◆ to_short_date_string()

std::string clan::DateTime::to_short_date_string ( ) const

yyyy-mm-dd

◆ to_short_datetime_string()

std::string clan::DateTime::to_short_datetime_string ( ) const

yyyy-mm-dd hh:mm:ss

◆ to_short_time_string()

std::string clan::DateTime::to_short_time_string ( ) const

hh:mm

◆ to_string()

std::string clan::DateTime::to_string ( ) const

Mon Feb 3 12:32:54 2008.

◆ to_ticks()

int64_t clan::DateTime::to_ticks ( ) const

Converts the date to the number of 100-nanosecond intervals since January 1, 1601 UTC.

◆ to_utc()

DateTime clan::DateTime::to_utc ( ) const

◆ update()

void clan::GameTime::update ( )

Updates time data for the frame to be rendered.

Call this function once at the start of a frame.

◆ wait_for_key()

void clan::ConsoleWindow::wait_for_key ( )

Waits until user hits a key.

This function does not do anything on Linux.

◆ what()

virtual const char* clan::Exception::what ( ) const
throw (
)
overridevirtual

Returns description of exception.

◆ work_completed() [1/2]

virtual void clan::WorkItem::work_completed ( )
inlinevirtual

Called by the WorkQueue thread to complete the work.

◆ work_completed() [2/2]

void clan::WorkQueue::work_completed ( const std::function< void()> &  func)

Queue some work to be executed on the main WorkQueue thread.

Variable Documentation

◆ data

template<typename T >
std::shared_ptr<T> clan::UserData< T >::data

◆ message

std::string clan::Exception::message

Description of exception.

◆ PI

const float clan::PI = 3.14159274101257f

◆ PI_D

const double clan::PI_D = 3.141592653589793115998

◆ PI_F

const float clan::PI_F = 3.14159274101257f

Friends

◆ Service_Impl

friend class Service_Impl
friend

◆ ThreadLocalStorage_Instance

friend class ThreadLocalStorage_Instance
friend