Cogs.Foundation
|
Namespaces | |
namespace | Collections |
Contains collection classes used to manage object storage. | |
namespace | ComponentModel |
Contains code for composing and managing entities built from components. | |
namespace | Details |
namespace | EasingFn |
namespace | Geometry |
namespace | IO |
namespace | Logging |
Contains logging functionality for the Cogs native library. | |
namespace | Memory |
namespace | Network |
namespace | Reflection |
Contains reflection support. | |
namespace | Threads |
Classes | |
struct | DirectoryEntry |
struct | FileContents |
Abstract base class storing data read from a file. More... | |
struct | FileEntry |
class | FileHandle |
class | FileSystemWatcher |
struct | Gesture |
class | Gestures |
class | ImmutableString |
Represents a non-copyable immutable string. More... | |
class | Interpolator |
struct | IntrusiveList |
struct | IntrusiveNode |
struct | Item |
class | Keyboard |
class | LLToENUConverter |
Converts WGS latitude-longitude coordinates to ENU local tangential east-north-up coordinate system. More... | |
struct | MemoryBufferBackedFileContents |
struct | MMapBackedFileContents |
class | Module |
Base class for managing libraries dynamically loaded at runtime. More... | |
class | ModuleAPI |
Helper class for shared libraries that implement the getPublicAPI function and provide a structure of function pointers that contain the module's public API. More... | |
class | Monitor |
Helper class for enumerating available displays on the host computer. More... | |
class | Mouse |
class | PlatformContext |
struct | Pointer |
Provides scoped storage for a raw pointer and corresponding deletion logic. More... | |
struct | Storage |
class | StringView |
Provides a weakly referenced view over the contents of a string. More... | |
class | Timer |
Old timer class. More... | |
struct | UniqueValue |
A value that is cleared when it is moved from. More... | |
struct | WindowData |
Typedefs | |
using | ComponentIndex = uint32_t |
Type used to track component indexes in pools. | |
using | SizeType = ComponentIndex |
Type used to track the size of pools. | |
template<typename T > | |
using | Atomic = std::atomic< T > |
using | PointerId = size_t |
typedef std::thread | Thread |
typedef std::mutex | Mutex |
typedef std::lock_guard< Mutex > | LockGuard |
typedef std::unique_lock< Mutex > | UniqueLock |
template<typename T > | |
using | Future = std::future< T > |
typedef int64_t | TimePerf |
typedef int64_t | Time |
Enumerations | |
enum struct | FileContentsHints : uint32_t { None = 0 , ZStdDecompress = 1 << 0 , BrotliDecompress = 1 << 1 } |
enum class | PointerType { Mouse , Touch , Count , Unknown } |
enum class | Key { A , B , C , D , E , F , G , H , I , J , K , L , M , N , O , P , Q , R , S , T , U , V , W , X , Y , Z , Zero , One , Two , Three , Four , Five , Six , Seven , Eight , Nine , Left , Right , Up , Down , Shift , LeftShift , RightShift , Control , LeftControl , RightControl , Alt , LeftAlt , RightAlt , CapsLock , Tab , Escape , Enter , Space , Insert , Delete , Backspace , Home , End , PageUp , PageDown , F1 , F2 , F3 , F4 , F5 , F6 , F7 , F8 , F9 , F10 , F11 , F12 , Count , None = -1 } |
enum | MouseButton : int { Left , Right , Middle , Count , NoButton } |
Functions | |
constexpr uint64_t | mortonCode (uint16_t i, uint16_t j, uint16_t k) |
Interleave bits of 3 values to form the 3-way Morton code. | |
constexpr uint32_t | mortonCode (uint16_t a, uint16_t b) |
Interleave bits of 2 values. | |
template<typename T > | |
bool | isPowerOfTwo (T x) |
uint8_t | roundUpToPowerOfTwo (uint8_t x) |
uint16_t | roundUpToPowerOfTwo (uint16_t x) |
uint16_t | roundDownToPowerOfTwo (uint16_t x) |
uint32_t | roundUpToPowerOfTwo (uint32_t x) |
uint64_t | roundUpToPowerOfTwo (uint64_t x) |
uint8_t | roundUpToPowerOfTwoShift (uint8_t x) |
uint16_t | roundUpToPowerOfTwoShift (uint16_t x) |
uint32_t | roundUpToPowerOfTwoShift (uint32_t x) |
uint64_t | roundUpToPowerOfTwoShift (uint64_t x) |
template<typename ClassType , typename FieldType > | |
size_t | memberOffset (FieldType ClassType::*ptr) |
Find the offset of a pointer to member in a class or struct. | |
constexpr uint32_t | make2CCLE (uint8_t a, uint8_t b) |
constexpr uint32_t | make2CCBE (uint8_t a, uint8_t b) |
constexpr uint32_t | make4CCLE (uint8_t a, uint8_t b, uint8_t c, uint8_t d) |
constexpr uint32_t | make4CCBE (uint8_t a, uint8_t b, uint8_t c, uint8_t d) |
const char * | getFoundationVersionString () |
template<typename T > | |
T | interpolateFn (const T &s, const T &d, float t) |
template<> | |
glm::quat | interpolateFn< glm::quat > (const glm::quat &s, const glm::quat &d, float t) |
COGSFOUNDATION_API size_t | murmur2 (const void *bytes, const size_t length) noexcept |
Implementation of the MurmurHash2 algorithm. | |
constexpr size_t | fnv1a (uint8_t data, size_t hashValue) noexcept |
Hashes a single byte using the fnv1a algorithm. | |
constexpr size_t | fnv1a (const void *bytes, size_t length, size_t hashValue=Details::FNV_offset_basis) noexcept |
Implementation of the FNV-1a algorithm for a block of memory. | |
constexpr size_t | hash () noexcept |
Simple getter function that returns the initial value for fnv1a hashing. | |
template<typename T , typename std::enable_if< std::is_integral< T >::value||std::is_enum< T >::value||std::is_floating_point< T >::value, int >::type * = nullptr> | |
constexpr size_t | hash (T data, size_t hashValue=hash()) noexcept |
Hash function for integer and floating point types. (And enums.) | |
constexpr size_t | hash (const char *str, size_t hashValue=hash()) noexcept |
Hash function for hashing Null terminated C character strings. | |
COGSFOUNDATION_API size_t | hashLowercase (std::string_view str, size_t hashValue=Cogs::hash()) noexcept |
Get the hash code of the string converted to lowercase. | |
constexpr size_t | hash (const void *mem, size_t size, size_t hashValue=hash()) noexcept |
Hash a non-descript block of memory. | |
constexpr size_t | hash (std::string_view str, size_t hashValue=hash()) noexcept |
Generic hash function specialization for strings (std::string, std::string_view, Cogs::StringView). | |
template<typename T , typename U > | |
constexpr size_t | hashSequence (const T &t, const U &u) |
Hash the last two items in a sequence of objects. | |
template<typename T , typename U , typename... Args> | |
constexpr size_t | hashSequence (const T &t, const U &u, Args... args) |
Calculates a single hash value from a sequence of objects. | |
COGSFOUNDATION_API void * | stbAlloc (size_t size, void *userData=nullptr) |
COGSFOUNDATION_API void * | stbRealloc (void *ptr, size_t oldSize, size_t newSize) |
COGSFOUNDATION_API void | stbFree (void *ptr, void *userData=nullptr) |
COGSFOUNDATION_API bool | isBeingDebugged () |
Return true if the application is running under a debugger. | |
COGSFOUNDATION_API std::string | getCallstack () |
Returns the current callstack as a string. | |
COGSFOUNDATION_API TimePerf | perfTime () |
High resolution performance timer. Returns an implementation defined absolute timestamp, can be subtracted to get a time duration. | |
COGSFOUNDATION_API Time | currentTime () |
High resolution clock time (NTP / UTC time). Returns an implementation defined absolute timestamp, can be subtracted to get a time duration. | |
COGSFOUNDATION_API TimePerf | perfTimeReference () |
Functions that provide a reference time point at the start of the application startup. Useful for application uptime or converting absolute timestamps to a narrow value range. | |
COGSFOUNDATION_API Time | currentTimeReference () |
COGSFOUNDATION_API int64_t | perfTimeToMicroseconds (TimePerf time) |
Convertion functions for timestamps. | |
COGSFOUNDATION_API int64_t | perfTimeToMilliseconds (TimePerf time) |
COGSFOUNDATION_API double | perfTimeToSeconds (TimePerf time) |
COGSFOUNDATION_API int64_t | currentTimeToMicroseconds (Time time) |
COGSFOUNDATION_API int64_t | currentTimeToMilliseconds (Time time) |
COGSFOUNDATION_API double | currentTimeToSeconds (Time time) |
template<typename T , typename DeleterFunction > | |
Pointer< T > | makePointer (T *t, DeleterFunction deleterFunc) |
Construct a Pointer<T> instance from the given pointer and deleter function. | |
std::ostream & | operator<< (std::ostream &stream, const Cogs::StringView &stringView) |
Stream operator out provided to make it possible to insert Cogs::StringView into streams. | |
std::string & | stringReplaceAll (std::string &str, std::string_view from, std::string_view to) |
bool | stringStartsWith (std::string_view str, std::string_view beginning) |
bool | stringEndsWith (std::string_view str, std::string_view ending) |
std::string | stringToLower (std::string_view input) |
std::string | stringToUpper (std::string_view input) |
std::string | stringConcatenate (std::initializer_list< std::string_view > strList) |
std::string | stringJoin (std::string_view separator, std::initializer_list< std::string_view > strList) |
bool | operator< (const StringView &left, const StringView &right) noexcept |
Lexicographically compare two string views. | |
bool | operator> (const StringView &left, const StringView &right) noexcept |
Lexicographically compare two string views. | |
bool | operator<= (const StringView &left, const StringView &right) noexcept |
Lexicographically compare two string views. | |
bool | operator>= (const StringView &left, const StringView &right) noexcept |
Lexicographically compare two string views. | |
bool | operator== (const char *left, const StringView &right) noexcept |
Char ptr equality operator. | |
bool | operator== (const StringView &left, const char *right) noexcept |
Char ptr equality operator. | |
bool | operator== (const std::string &left, const StringView &right) noexcept |
std::string equality operator. | |
bool | operator== (const std::string_view &left, const StringView &right) noexcept |
std::string_view equality operator. | |
Variables | |
constexpr Cogs::Logging::Log | logger = Cogs::Logging::getLogger("FileSystemWatcher") |
Main Cogs namespace.
Define we can check on if size_t literal suffix is defined.
Hashing functions for COGS.
DO NOT mix these hashing functions with STL std::hash for same data types. DO NOT serialize hash values. 32 and 64 bit incompatible. No guarantee for backwards compatibility.
using Cogs::Atomic = typedef std::atomic<T> |
using Cogs::ComponentIndex = typedef uint32_t |
Type used to track component indexes in pools.
using Cogs::Future = typedef std::future<T> |
typedef std::lock_guard<Mutex> Cogs::LockGuard |
typedef std::mutex Cogs::Mutex |
using Cogs::PointerId = typedef size_t |
using Cogs::SizeType = typedef ComponentIndex |
Type used to track the size of pools.
typedef std::thread Cogs::Thread |
typedef int64_t Cogs::Time |
typedef int64_t Cogs::TimePerf |
typedef std::unique_lock<Mutex> Cogs::UniqueLock |
|
strong |
|
strong |
enum Cogs::MouseButton : int |
|
strong |
Cogs::Time Cogs::currentTime | ( | ) |
High resolution clock time (NTP / UTC time). Returns an implementation defined absolute timestamp, can be subtracted to get a time duration.
Referenced by Cogs::Timer::currentTimeMicroseconds(), and Cogs::Timer::currentTimeMilliseconds().
Cogs::Time Cogs::currentTimeReference | ( | ) |
int64_t Cogs::currentTimeToMicroseconds | ( | Time | time | ) |
Referenced by Cogs::Timer::currentTimeMicroseconds().
int64_t Cogs::currentTimeToMilliseconds | ( | Time | time | ) |
Referenced by Cogs::Timer::currentTimeMilliseconds().
double Cogs::currentTimeToSeconds | ( | Time | time | ) |
|
constexprnoexcept |
Implementation of the FNV-1a algorithm for a block of memory.
bytes | Pointer to a sequence of bytes. |
length | The number of bytes in the sequence. |
hashValue | Initial hash value to be used. This allows you to chain hash calls together. |
References fnv1a().
|
constexprnoexcept |
Hashes a single byte using the fnv1a algorithm.
References Cogs::Details::FNV_prime.
COGSFOUNDATION_API std::string Cogs::getCallstack | ( | ) |
Returns the current callstack as a string.
const char * Cogs::getFoundationVersionString | ( | ) |
|
constexprnoexcept |
Simple getter function that returns the initial value for fnv1a hashing.
References Cogs::Details::FNV_offset_basis.
Referenced by Cogs::StringView::hash(), Cogs::ComponentModel::Component::hash(), hashLowercase(), hashSequence(), Cogs::Reflection::Name::Name(), std::hash< Cogs::StringView >::operator()(), and Cogs::Logging::parseCategoryString().
|
constexprnoexcept |
Hash function for hashing Null terminated C character strings.
References fnv1a().
|
constexprnoexcept |
Hash a non-descript block of memory.
References fnv1a().
|
constexprnoexcept |
Generic hash function specialization for strings (std::string, std::string_view, Cogs::StringView).
References fnv1a().
|
constexprnoexcept |
Hash function for integer and floating point types. (And enums.)
References fnv1a().
|
noexcept |
Get the hash code of the string converted to lowercase.
Lowercase is here defined as default "C" locale, i.e., A-Z is converted to a-z.
References hash().
Referenced by Cogs::StringView::hashLowercase(), and Cogs::Logging::parseCategoryString().
Hash the last two items in a sequence of objects.
References hash().
Referenced by Cogs::Logging::ThrottledConsumer::consumeMessage(), and hashSequence().
Calculates a single hash value from a sequence of objects.
References hash(), and hashSequence().
Referenced by Cogs::Interpolator< T >::process().
|
inline |
COGSFOUNDATION_API bool Cogs::isBeingDebugged | ( | ) |
Return true if the application is running under a debugger.
Referenced by Cogs::Logging::ConsoleLogger::ConsoleLogger().
Returns true if x is a power of two.
Referenced by Cogs::Collections::FixedIndexQueue< Element, IndexBaseType >::resize().
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
Pointer< T > Cogs::makePointer | ( | T * | t, |
DeleterFunction | deleterFunc | ||
) |
Construct a Pointer<T> instance from the given pointer and deleter function.
Allows simple template type deduction for the T parameter.
T | Type of the pointer given. |
DeleterFunction | Type of deleter to associate with the pointer. |
t | Pointer to store. |
deleterFunc | Deleter function instance. |
|
inline |
Find the offset of a pointer to member in a class or struct.
The offset is found by constructing a member pointer inside an instance of the type at memory address zero. The pointers address can then be directly converted to a byte offset from the start of the instance.
Referenced by Cogs::ComponentModel::Component::getFieldId(), and Cogs::Reflection::Type::getFieldId().
|
constexpr |
Interleave bits of 2 values.
|
constexpr |
|
noexcept |
Implementation of the MurmurHash2 algorithm.
bytes | Pointer to a sequence of bytes. |
length | Length of the sequence of bytes to operate on. |
|
inlinenoexcept |
Lexicographically compare two string views.
|
inline |
Stream operator out provided to make it possible to insert Cogs::StringView into streams.
stream | Stream object to output to. |
stringView | StringView instance to output. |
|
inlinenoexcept |
Lexicographically compare two string views.
|
inlinenoexcept |
Char ptr equality operator.
|
inlinenoexcept |
std::string equality operator.
|
inlinenoexcept |
std::string_view equality operator.
|
inlinenoexcept |
Char ptr equality operator.
|
inlinenoexcept |
Lexicographically compare two string views.
|
inlinenoexcept |
Lexicographically compare two string views.
Cogs::TimePerf Cogs::perfTime | ( | ) |
High resolution performance timer. Returns an implementation defined absolute timestamp, can be subtracted to get a time duration.
Referenced by Cogs::Timer::elapsedMicroseconds(), Cogs::Timer::elapsedMilliseconds(), Cogs::Timer::elapsedSeconds(), Cogs::Timer::start(), and Cogs::Timer::stop().
Cogs::TimePerf Cogs::perfTimeReference | ( | ) |
Functions that provide a reference time point at the start of the application startup. Useful for application uptime or converting absolute timestamps to a narrow value range.
int64_t Cogs::perfTimeToMicroseconds | ( | TimePerf | time | ) |
Convertion functions for timestamps.
Referenced by Cogs::Timer::elapsedMicroseconds().
int64_t Cogs::perfTimeToMilliseconds | ( | TimePerf | time | ) |
Referenced by Cogs::Timer::elapsedMilliseconds().
double Cogs::perfTimeToSeconds | ( | TimePerf | time | ) |
Referenced by Cogs::Timer::elapsedSeconds().
|
inline |
|
inline |
Round a number up to the next number of two, or return itself if the number already is a power of two.
|
inline |
Round a number up to the next number of two, or return itself if the number already is a power of two.
|
inline |
Round a number up to the next number of two, or return itself if the number already is a power of two.
|
inline |
Round a number up to the next number of two, or return itself if the number already is a power of two.
Referenced by roundUpToPowerOfTwoShift().
|
inline |
Rounds x up to the next number of two if it is not already a number of two and returns the number of shifts this number is.
References roundUpToPowerOfTwo().
|
inline |
Rounds x up to the next number of two if it is not already a number of two and returns the number of shifts this number is.
References roundUpToPowerOfTwo().
|
inline |
Rounds x up to the next number of two if it is not already a number of two and returns the number of shifts this number is.
References roundUpToPowerOfTwo().
|
inline |
Rounds x up to the next number of two if it is not already a number of two and returns the number of shifts this number is.
References roundUpToPowerOfTwo().
Referenced by Cogs::Collections::FixedIndexQueue< Element, IndexBaseType >::shrink().
void * Cogs::stbAlloc | ( | size_t | size, |
void * | userData = nullptr |
||
) |
void Cogs::stbFree | ( | void * | ptr, |
void * | userData = nullptr |
||
) |
void * Cogs::stbRealloc | ( | void * | ptr, |
size_t | oldSize, | ||
size_t | newSize | ||
) |
COGSFOUNDATION_API std::string Cogs::stringConcatenate | ( | std::initializer_list< std::string_view > | strList | ) |
|
inline |
COGSFOUNDATION_API std::string Cogs::stringJoin | ( | std::string_view | separator, |
std::initializer_list< std::string_view > | strList | ||
) |
|
inline |
|
inline |
|
inline |
|
inline |
|
constexpr |
Referenced by Cogs::Memory::Allocator::allocate(), Cogs::Network::ConnectionBase::bind(), Cogs::Network::ConnectionUDP::bind(), Cogs::Network::ConnectionBase::close(), Cogs::Network::ConnectionBase::create(), Cogs::Network::ConnectionTCP::disconnect(), Cogs::FileHandle::getSize(), Cogs::Network::ConnectionTCP::listen(), Cogs::FileHandle::map(), Cogs::FileHandle::open(), Cogs::Gestures::pointerUp(), Cogs::Network::PrintAdapters(), Cogs::Network::ConnectionHub::processOutgoing(), Cogs::FileHandle::read(), Cogs::IO::readFileAsync(), Cogs::Network::ConnectionTCP::reconnect(), Cogs::ComponentModel::ComponentHandle::resolve(), Cogs::Gestures::update(), Cogs::Network::UpdateAdapters(), and Cogs::FileHandle::write().