Classes | |
| class | AssertException |
| Exception thrown when ASSERT*() evaluates false. More... | |
| class | ConfReader |
| Template Method to read human-editable conf file via C++ stream. More... | |
| class | ConfigFile |
| Storing and reading configuration (key,value) to a file. More... | |
| class | Dlink |
| Class for a link in a Dlist. More... | |
| class | Dlist |
| Template class for a circular double-link list. More... | |
| class | DlistIterator |
| Iterator to traverse a Dlist. More... | |
| class | Event |
| Broadcasts events to registered listener functors. More... | |
| class | Global |
| Global class collects globals as members to determine their order of construction. More... | |
| class | Nest |
| A container-of-containers class. More... | |
| class | Random |
| Generates random numbers from a per-thread safe. More... | |
| class | SafePtr |
| Template class to shield an object being deleting by its users. More... | |
| class | Settings |
| Global program settings. More... | |
| class | Shared |
| Base class containing a reference-count maintained by SharedPtr. More... | |
| class | Stack |
| Stack template class. More... | |
| class | BaseStats |
| Statistics. More... | |
| class | Streams |
| Threaded streams. More... | |
| class | StreambufFile2 |
| Streambuf class that can write to one or two files (a confluence/fork). More... | |
| struct | ThreadMemoryHeader |
| Defines size and free space in "thread memory" allocated on heap. More... | |
| class | Thread |
| Schedules threads and wraps OS thread library. More... | |
| class | Atomic |
| Atomic operations. More... | |
| class | Busy |
| Class to automatically increment and decrement a busy count. More... | |
| class | AutoLock |
| Automatically lock/unlock a mutex inside a C++ block. More... | |
| class | RushLock |
| RushLock is a NON-RECURSIVE spinlock (limited use). More... | |
| class | FastLock |
| FastLock is a recursive spinlock. More... | |
| class | SlowLock |
| SlowLock is a a recursive locking mechanism for slow functions. More... | |
| class | NoLock |
| NOP lock. More... | |
| class | PerThreadPtr |
| Magic pointer to per-thread object (thread local storage). More... | |
| class | Threadable |
| Empty class to indicate a fully thread-safe class. More... | |
| class | SemiThreadable |
| Empty class to indicate a class having imperfect thread-safety. More... | |
| class | NonThreadable |
| Empty class to indicate a class cannot be executed concurrently. More... | |
| class | Void |
| class | bool0 |
| class | int0 |
| class | uint0 |
| class | Bits |
| Portable bitfield class. More... | |
| struct | Seconds |
| Time units. More... | |
| struct | Milliseconds |
| struct | Microseconds |
| class | AbstractIterator |
| Abstract class for Iterator objects. More... | |
| class | STLIterator |
| Iterator object for STL vectors. More... | |
| class | Multivar |
| A variable with multiple values of the same type. More... | |
| class | Percent |
| Percent. More... | |
| class | StringBuf |
| Basic string buffer class. More... | |
| class | Array |
| Array template class similar to STL vector but checks index and can be Shared. More... | |
| class | TinyArray |
| Light-weight fixed-length Array class with index-checking (if DEBUG==2). More... | |
| class | SmallArray |
| Pretends to have a variable-size (but underlying array is fixed-size). More... | |
| class | SortedArray |
| Sorted array that provides read-only operator[]. More... | |
| class | TempArray |
| Template class for reusing a pre-allocated array for speed. More... | |
| class | Array2D |
| 2D array that clamps indexs. More... | |
| class | Unique |
| Base class for objects constrained to having unique values. More... | |
| class | UniqueFactory |
| Factory that destroys duplicate objects and returns unique ones. More... | |
| class | UniquePtr |
| Smart pointer that contrains objects to having unique values. More... | |
| class | SharedPtr |
| Smart pointer that maintains reference-count of Shared object. More... | |
| class | SharedPtrNull |
| Variant of SharedPtr that can be NULL. More... | |
| class | SharedPtrLocked |
| Smart pointer that maintains reference-count of Shared object. More... | |
| class | SharedPtrNullLocked |
| Variant of SharedPtr that can be NULL. More... | |
| class | shptr |
| Abbreviation for SharedPtr. More... | |
| class | shptr0 |
| Abbreviation for SharedPtrNull. More... | |
| class | uniptr |
| Abbreviation for UniquePtr (pointer to unique object). More... | |
Namespaces | |
| namespace | defs |
| namespace | restrict |
| Limited-use. | |
Typedefs | |
| typedef int8_t | int8 |
| typedef uint8_t | uint8 |
| typedef int16_t | int16 |
| typedef uint16_t | uint16 |
| typedef int32_t | int32 |
| typedef uint32_t | uint32 |
| typedef int64_t | int64 |
| typedef uint64_t | uint64 |
| typedef unsigned int | typesig_t |
Enumerations | |
| enum | { TYPESIG_INVALID = 0, TYPESIG = 0x1234aabb, TYPESIG_DLINK, TYPESIG_DLIST, TYPESIG_ITER, TYPESIG_STACK, TYPESIG_SHARED, TYPESIG_SHARED_PTR, TYPESIG_UNIQUE, TYPESIG_UNIQUE_FACTORY, TYPESIG_CONFIG_TUPLE, TYPESIG_SORTED_ARRAY, TYPESIG_BASE_USER } |
Functions | |
| static void | EXIT0 (void) |
| void | Init (int argc, char **argv, const string &programName) |
| void | Cleanup (void) |
| void | EXIT (int exitCode) |
| void | SetProgramName (const string &programName) |
| string | GetProgramName (void) |
| static void | SelfCheck (void) |
| NOINLINE void | ASSERT_STACK_OBJECT (const void *obj) |
| NOINLINE void | ASSERT_PERSISTENT_OBJECT (const void *obj) |
| void | ASSERT_MAIN_THREAD (void) |
| bool | CompareTuples (const ConfigFile::ConfigTuple &t1, const ConfigFile::ConfigTuple &t2) |
| unsigned long | MemUsed (void) |
| void | MeasureTime (void(*func)(long), long funcArg, const string &funcName) |
| bool | IfFileExists (const string &fname) |
| long | FileSize (FILE *file) |
| bool | ReadFile (const string &fname, string &obuf) |
| bool | ReadFile (const string &fname, StringBuf &strbuf) |
| bool | ReadFileGzip (const string &fname, string &obuf, const uint chunkLen) |
| bool | RemoveFile (const string &fname) |
| void | RemoveSuffix (string &fname, const string &suffix) |
| bool | IfAbsPath (const string &path) |
| bool | IfDirExists (const string &dirname) |
| bool | FilesInDir (const string &dirname, vector< string > &vec) |
| string | GetCwd (void) |
| INLINE bool | FEQ (fp a, fp b) |
| INLINE bool | FNE (fp a, fp b) |
| INLINE bool | FEQ_FLOAT_LARGE (fp f) |
| INLINE bool | FEQ_FLOAT_SMALL (fp f) |
| template<typename FP> | |
| bool | FEQ (const FP a, const FP b) |
| template<typename FP> | |
| bool | FEQ (const FP a, const FP b, const uint fracDigits) |
| Slower but flexible variant of FEQ(). | |
| INLINE int | Clamp (int i, int limit) |
| INLINE uint8 | ClampFF (uint i) |
| INLINE uint8 | ClampFF (int i) |
| INLINE uint8 | ClampFF (fp f) |
| INLINE fp | Clamp1 (fp f) |
| INLINE fp | Clamp (fp f, fp low=0.0, fp high=1.0) |
| INLINE fp | PrintableMegabyte (const long bytes) |
| Convert bytes for printing as "n.nMB". | |
| template<typename T> | |
| T * | PTR (vector< T > &v) |
| template<typename T> | |
| const T * | CONST_PTR (const vector< T > &v) |
| template<typename SEQCONT> | |
| void | Expand (SEQCONT &seqcont, uint idx) |
| template<typename T> | |
| void | Remove (vector< T > &container, T item) |
| template<typename T> | |
| void | Remove (deque< T > &container, T item) |
| template<typename T> | |
| void | Remove (list< T > &container, T item) |
| template<typename KEY> | |
| void | Remove (set< KEY > &container, KEY item) |
| template<typename KEY, typename VAL> | |
| void | Remove (map< KEY, VAL > &container, VAL item) |
| template<typename CONTAINER> | |
| bool | IfDuplicate (const CONTAINER &c1, const CONTAINER &c2) |
| int | Argi (int idx, int argc_, char **argv_) |
| float | Argf (int idx, int argc_, char **argv_) |
| string | Argstr (int idx, int argc_, char **argv_) |
| void | CmdargDone (int i, int n) |
| bool | IfCmdargDone (int i) |
| template<typename T> | |
| bool | operator== (const SafePtr< T > &ptr, const T *obj) |
| template<typename T> | |
| bool | operator!= (const SafePtr< T > &ptr, const T *obj) |
| template<typename T> | |
| bool | operator== (const T *obj, const SafePtr< T > &ptr) |
| template<typename T> | |
| bool | operator!= (const T *obj, const SafePtr< T > &ptr) |
| template<typename T1, typename T2> | |
| bool | operator== (const T1 *obj, const SafePtr< T2 > &ptr) |
| template<typename T1, typename T2> | |
| bool | operator!= (const T1 *obj, const SafePtr< T2 > &ptr) |
| template<typename T1, typename T2> | |
| bool | operator== (const SafePtr< T1 > &ptr1, const SafePtr< T2 > &ptr2) |
| template<typename T1, typename T2> | |
| bool | operator!= (const SafePtr< T1 > &ptr1, const SafePtr< T2 > &ptr2) |
| template<typename T> | |
| bool | operator< (const SafePtr< T > &ptr1, const SafePtr< T > &ptr2) |
| ostream & | operator<< (ostream &strm, const Settings &settings) |
| const string & | GetDataDir (void) |
| template<typename CONTAINER> | |
| void | InsertionSort (CONTAINER &cont) |
| ostream & | operator<< (ostream &strm, const BaseStats &o) |
| bool | StreamToNextLine (istream &strm) |
| bool | StreamPeek (istream &strm, const string &word) |
| static void * | ThreadMemory_Align (void *const p) |
| static void | ThreadMemory_WriteHeader (void *block, const uint size) |
| static bool | ThreadMemory_SetFreeSpace (void *block, void *freeSpace) |
| static void * | ThreadMemory_GetFreeSpace (void *block) |
| static void | ThreadMemory_CheckSignature (const void *block) |
| void * | SuballocateThreadMemory (const uint bytes) |
| template<uint CNT, typename T> | |
| bool | operator< (const TinyArray< CNT, T > &a1, const TinyArray< CNT, T > &a2) |
| template<uint FIXED_SIZE, typename T> | |
| bool | operator< (const SmallArray< FIXED_SIZE, T > &a1, const SmallArray< FIXED_SIZE, T > &a2) |
| template<typename T> | |
| bool | operator== (const UniquePtr< T > &a, const UniquePtr< T > &b) |
| template<typename T> | |
| bool | operator!= (const UniquePtr< T > &a, const UniquePtr< T > &b) |
| template<typename T> | |
| bool | operator< (const UniquePtr< T > &a, const UniquePtr< T > &b) |
Variables | |
| static string | sProgramName |
| static const string | BASE_CONFIG_FILE_VERSION_STR = "(gfx::ConfigFile v2)" |
| const uint | MAX_PATH = 256 |
| Global | global |
| static bool | sCmdargDone [100] |
| const fp | RAND_MAX_RECIP = 1.0 / fp(RAND_MAX) |
| static char | sDummyArg0 [1] = { 0 } |
| static char * | sDummyArgv [] = { sDummyArg0 } |
| Settings | gSettings |
| static const uint32 | THREAD_MEMORY_SIG = 0xdead8086 |
| const uint | INT_BITS = sizeof(int) * 8 |
| const uint | LONG_BITS = sizeof(long) * 8 |
| const uint | PTR_BITS = sizeof(void*) * 8 |
| const typesig_t | TYPESIG_MAX = 0xffffffff |
| typedef int16_t base::int16 |
| typedef int32_t base::int32 |
| typedef int64_t base::int64 |
| typedef int8_t base::int8 |
| typedef unsigned int base::typesig_t |
| typedef uint16_t base::uint16 |
| typedef uint32_t base::uint32 |
| typedef uint64_t base::uint64 |
| typedef uint8_t base::uint8 |
| anonymous enum |
| float base::Argf | ( | int | idx, | |
| int | argc_, | |||
| char ** | argv_ | |||
| ) |
| int base::Argi | ( | int | idx, | |
| int | argc_, | |||
| char ** | argv_ | |||
| ) |
Safely process a cmd-line arg.
| string base::Argstr | ( | int | idx, | |
| int | argc_, | |||
| char ** | argv_ | |||
| ) |
| void base::ASSERT_MAIN_THREAD | ( | void | ) |
Assert this is the main thread.
| void base::ASSERT_PERSISTENT_OBJECT | ( | const void * | obj | ) |
| void base::ASSERT_STACK_OBJECT | ( | const void * | obj | ) |
ASSERT_PERSISTENT_OBJECT(): Assert that an object is in persistent storage (ie, not on call stack).
ASSERT_STACK_OBJECT(): Assert that an object is a local object on call stack.
Technically, these aren't portable. But in fact, most OSs place a grow-down stack at the top of the address space of a process.
These are real functions, rather than macros, to induce a function call to place the object and a known stack variable in separate stack frames. Otherwise, if both were on the same stack frame, there's no way to predict whether the compiler places one above or below the other.
| INLINE int base::Clamp | ( | int | i, | |
| int | limit | |||
| ) |
Clamp signed integer in range {0,...,limit}.
| INLINE uint8 base::ClampFF | ( | int | i | ) |
Clamp value to 0xFF. ClampFF(uint) is the fastest.
| void gfx::Cleanup | ( | void | ) |
Cleanup this library.
| void base::CmdargDone | ( | int | i, | |
| int | n | |||
| ) |
| bool base::CompareTuples | ( | const ConfigFile::ConfigTuple & | t1, | |
| const ConfigFile::ConfigTuple & | t2 | |||
| ) |
Used to sort firstly by type, secondly by key.
| const T* base::CONST_PTR | ( | const vector< T > & | v | ) | [inline] |
| void base::EXIT | ( | int | exitCode | ) |
Exit to MSDOS.
| static void base::EXIT0 | ( | void | ) | [static] |
| void base::Expand | ( | SEQCONT & | seqcont, | |
| uint | idx | |||
| ) | [inline] |
Expand a sequential STL container if necessary. Useful before operator[] to ensure container can hold it.
| bool base::FEQ | ( | const FP | a, | |
| const FP | b, | |||
| const uint | fracDigits | |||
| ) | [inline] |
Slower but flexible variant of FEQ().
| bool base::FEQ | ( | const FP | a, | |
| const FP | b | |||
| ) | [inline] |
Compare floats: compare full integral part, compare fracDigits of fractional part. Eg: FEQ( 1.234, 1.234, 4 ) Note: In practice, usually, fracDigits should be small, or miscompares will be frequent. Tested by tests/math.cc.
Cope with floating-point inaccuracy. Return true if two floats are approximately equal.
| INLINE bool base::FEQ_FLOAT_LARGE | ( | fp | f | ) |
| INLINE bool base::FEQ_FLOAT_SMALL | ( | fp | f | ) |
| bool base::FilesInDir | ( | const string & | dirname, | |
| vector< string > & | vec | |||
| ) |
Fills a STL vector with filenames from a directory.
* Example of usage:
* vector<string> files;
* if ( FilesInDir( "/tmp", files ) )
* {
* vector<string>::iterator iter;
* for ( iter = files.begin(); iter != files.end(); ++iter )
* cout << *iter << "\n";
* }
* | long base::FileSize | ( | FILE * | file | ) |
| string base::GetCwd | ( | void | ) |
| const string & base::GetDataDir | ( | void | ) |
| string base::GetProgramName | ( | void | ) |
| bool base::IfAbsPath | ( | const string & | path | ) |
| bool base::IfCmdargDone | ( | int | i | ) |
| bool base::IfDirExists | ( | const string & | dirname | ) |
| bool base::IfDuplicate | ( | const CONTAINER & | c1, | |
| const CONTAINER & | c2 | |||
| ) | [inline] |
| bool base::IfFileExists | ( | const string & | fname | ) |
| void base::Init | ( | int | argc, | |
| char ** | argv, | |||
| const string & | programName | |||
| ) |
Initialize this library.
| void base::InsertionSort | ( | CONTAINER & | cont | ) | [inline] |
Insertion sort for STL container (vector or deque). Insertion sort is optimal for "almost sorted" or "completely sorted" heaps.
| void base::MeasureTime | ( | void(*)(long) | func, | |
| long | funcArg, | |||
| const string & | funcName | |||
| ) |
Measure the amount of time a function takes.
| unsigned long base::MemUsed | ( | void | ) |
Return total amount of bytes allocated.
| bool base::operator!= | ( | const UniquePtr< T > & | a, | |
| const UniquePtr< T > & | b | |||
| ) | [inline] |
| bool base::operator!= | ( | const SafePtr< T1 > & | ptr1, | |
| const SafePtr< T2 > & | ptr2 | |||
| ) | [inline] |
| bool base::operator!= | ( | const T1 * | obj, | |
| const SafePtr< T2 > & | ptr | |||
| ) | [inline] |
| bool base::operator!= | ( | const T * | obj, | |
| const SafePtr< T > & | ptr | |||
| ) | [inline] |
| bool base::operator!= | ( | const SafePtr< T > & | ptr, | |
| const T * | obj | |||
| ) | [inline] |
| bool base::operator< | ( | const UniquePtr< T > & | a, | |
| const UniquePtr< T > & | b | |||
| ) | [inline] |
| bool base::operator< | ( | const SmallArray< FIXED_SIZE, T > & | a1, | |
| const SmallArray< FIXED_SIZE, T > & | a2 | |||
| ) | [inline] |
| bool base::operator< | ( | const TinyArray< CNT, T > & | a1, | |
| const TinyArray< CNT, T > & | a2 | |||
| ) | [inline] |
| bool base::operator< | ( | const SafePtr< T > & | ptr1, | |
| const SafePtr< T > & | ptr2 | |||
| ) | [inline] |
| ostream & base::operator<< | ( | ostream & | strm, | |
| const BaseStats & | o | |||
| ) |
operator<<(BaseStats)
| ostream & base::operator<< | ( | ostream & | strm, | |
| const Settings & | settings | |||
| ) |
Print Settings configuration.
| bool base::operator== | ( | const UniquePtr< T > & | a, | |
| const UniquePtr< T > & | b | |||
| ) | [inline] |
| bool base::operator== | ( | const SafePtr< T1 > & | ptr1, | |
| const SafePtr< T2 > & | ptr2 | |||
| ) | [inline] |
| bool base::operator== | ( | const T1 * | obj, | |
| const SafePtr< T2 > & | ptr | |||
| ) | [inline] |
| bool base::operator== | ( | const T * | obj, | |
| const SafePtr< T > & | ptr | |||
| ) | [inline] |
| bool base::operator== | ( | const SafePtr< T > & | ptr, | |
| const T * | obj | |||
| ) | [inline] |
| INLINE fp base::PrintableMegabyte | ( | const long | bytes | ) |
Convert bytes for printing as "n.nMB".
| T* base::PTR | ( | vector< T > & | v | ) | [inline] |
Get raw C array from STL vector. &v[0] is a STL idiom.
| bool base::ReadFile | ( | const string & | fname, | |
| StringBuf & | strbuf | |||
| ) |
| bool base::ReadFile | ( | const string & | fname, | |
| string & | obuf | |||
| ) |
Read a file into a C++ string.
| bool base::ReadFileGzip | ( | const string & | fname, | |
| string & | obuf, | |||
| const uint | chunkLen | |||
| ) |
Decompress a gzip-compressed file (.gz) using zlib functions into a C++ string.
| fname | ||
| obuf | Output buffer. | |
| chunkLen | Default arg. For speed, pass expected size of decompressed buffer. |
| void base::Remove | ( | map< KEY, VAL > & | container, | |
| VAL | item | |||
| ) | [inline] |
| void base::Remove | ( | set< KEY > & | container, | |
| KEY | item | |||
| ) | [inline] |
| void base::Remove | ( | list< T > & | container, | |
| T | item | |||
| ) | [inline] |
| void base::Remove | ( | deque< T > & | container, | |
| T | item | |||
| ) | [inline] |
| void base::Remove | ( | vector< T > & | container, | |
| T | item | |||
| ) | [inline] |
Remove() is a compatible way to remove items from various STL containers. Does NOT destroy/delete items.
| bool base::RemoveFile | ( | const string & | fname | ) |
Delete a file.
| void base::RemoveSuffix | ( | string & | fname, | |
| const string & | suffix | |||
| ) |
Remove suffix from a pathname.
| static void base::SelfCheck | ( | void | ) | [static] |
Ensure assumptions of this code hold on this platform. A serious failure causes program to exit.
| void base::SetProgramName | ( | const string & | programName | ) |
Set the program's name to let the user know which program had errors.
| bool base::StreamPeek | ( | istream & | strm, | |
| const string & | word | |||
| ) |
Peek input stream.
| bool base::StreamToNextLine | ( | istream & | strm | ) |
Jump to the next line.
| void * base::SuballocateThreadMemory | ( | const uint | bytes | ) |
| static void* base::ThreadMemory_Align | ( | void *const | p | ) | [inline, static] |
| static void base::ThreadMemory_CheckSignature | ( | const void * | block | ) | [inline, static] |
Thread memory has signature bytes to detect memory corruption.
| static void* base::ThreadMemory_GetFreeSpace | ( | void * | block | ) | [inline, static] |
Return address of free space in thread memory.
| static bool base::ThreadMemory_SetFreeSpace | ( | void * | block, | |
| void * | freeSpace | |||
| ) | [inline, static] |
Assign pointer to free space.
| static void base::ThreadMemory_WriteHeader | ( | void * | block, | |
| const uint | size | |||
| ) | [inline, static] |
Assign pointer to free space.
const string base::BASE_CONFIG_FILE_VERSION_STR = "(gfx::ConfigFile v2)" [static] |
| const uint base::INT_BITS = sizeof(int) * 8 |
| const uint base::LONG_BITS = sizeof(long) * 8 |
| const uint base::MAX_PATH = 256 |
| const uint base::PTR_BITS = sizeof(void*) * 8 |
| const fp base::RAND_MAX_RECIP = 1.0 / fp(RAND_MAX) |
bool base::sCmdargDone[100] [static] |
Functions for marking a command-line arg as "done". For helping to catch unrecognized args.
| i | argv[i] | |
| n | How many consecutive args are "done" (default n=1). |
char base::sDummyArg0[1] = { 0 } [static] |
char* base::sDummyArgv[] = { sDummyArg0 } [static] |
string base::sProgramName [static] |
const uint32 base::THREAD_MEMORY_SIG = 0xdead8086 [static] |
| const typesig_t base::TYPESIG_MAX = 0xffffffff |
Palomino 3D Engine documents generated by doxygen 1.5.3 on Fri Nov 23 11:26:18 2007