mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2025-03-25 13:49:56 -04:00
Cleanup: utility classes
This commit is contained in:
parent
a0f1ccf68d
commit
7aa7daa55f
@ -25,10 +25,8 @@
|
||||
|
||||
#include "DataTree.h"
|
||||
#include <fstream>
|
||||
#include <math.h>
|
||||
#include <iomanip>
|
||||
#include <locale>
|
||||
#include <stdlib.h>
|
||||
#include <cstdlib>
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
@ -48,10 +46,7 @@ DataElement::DataElement(DataElement &cloneFrom) : data_type(cloneFrom.getDataTy
|
||||
//
|
||||
}
|
||||
|
||||
DataElement::~DataElement() {
|
||||
//nothing
|
||||
}
|
||||
|
||||
DataElement::~DataElement() = default;
|
||||
|
||||
|
||||
char * DataElement::getDataPointer() {
|
||||
@ -91,7 +86,7 @@ void DataElement::set(const std::set<string> &strset_in) {
|
||||
|
||||
vector<string> tmp_vect;
|
||||
|
||||
for (auto single_string : strset_in) {
|
||||
for (const auto& single_string : strset_in) {
|
||||
tmp_vect.push_back(single_string);
|
||||
}
|
||||
|
||||
@ -120,14 +115,14 @@ void DataElement::get(std::set<string> &strset_out) {
|
||||
|
||||
strset_out.clear();
|
||||
|
||||
for (auto single_string : tmp_vect) {
|
||||
for (const auto& single_string : tmp_vect) {
|
||||
strset_out.insert(single_string);
|
||||
}
|
||||
}
|
||||
|
||||
std::string DataElement::toString() {
|
||||
int dataType = getDataType();
|
||||
std::string strValue = "";
|
||||
std::string strValue;
|
||||
|
||||
try {
|
||||
if (dataType == DATA_STRING) {
|
||||
@ -151,7 +146,7 @@ std::string DataElement::toString() {
|
||||
else {
|
||||
std::cout << "Unhandled DataElement toString for type: " << dataType << std::endl;
|
||||
}
|
||||
} catch (DataTypeMismatchException e) {
|
||||
} catch (const DataTypeMismatchException &e) {
|
||||
std::cout << "toString() DataTypeMismatch: " << dataType << std::endl;
|
||||
}
|
||||
|
||||
@ -160,16 +155,16 @@ std::string DataElement::toString() {
|
||||
|
||||
/* DataNode class */
|
||||
|
||||
DataNode::DataNode(): parentNode(NULL), ptr(0) {
|
||||
DataNode::DataNode(): parentNode(nullptr), ptr(0) {
|
||||
data_elem = new DataElement();
|
||||
}
|
||||
|
||||
DataNode::DataNode(const char *name_in): parentNode(NULL), ptr(0) {
|
||||
DataNode::DataNode(const char *name_in): parentNode(nullptr), ptr(0) {
|
||||
node_name = name_in;
|
||||
data_elem = new DataElement();
|
||||
}
|
||||
|
||||
DataNode::DataNode(const char *name_in, DataNode &cloneFrom): parentNode(NULL), ptr(0) {
|
||||
DataNode::DataNode(const char *name_in, DataNode &cloneFrom): parentNode(nullptr), ptr(0) {
|
||||
node_name = name_in;
|
||||
data_elem = new DataElement(*cloneFrom.element());
|
||||
|
||||
@ -180,20 +175,18 @@ DataNode::DataNode(const char *name_in, DataNode &cloneFrom): parentNode(NULL),
|
||||
}
|
||||
}
|
||||
|
||||
DataNode::DataNode(const char *name_in, DataElement &cloneFrom): parentNode(NULL), ptr(0) {
|
||||
DataNode::DataNode(const char *name_in, DataElement &cloneFrom): parentNode(nullptr), ptr(0) {
|
||||
node_name = name_in;
|
||||
data_elem = new DataElement(cloneFrom);
|
||||
}
|
||||
|
||||
DataNode::~DataNode() {
|
||||
while (children.size()) {
|
||||
while (!children.empty()) {
|
||||
DataNode *del = children.back();
|
||||
children.pop_back();
|
||||
delete del;
|
||||
}
|
||||
if (data_elem) {
|
||||
delete data_elem;
|
||||
}
|
||||
delete data_elem;
|
||||
}
|
||||
|
||||
void DataNode::setName(const char *name_in) {
|
||||
@ -223,7 +216,7 @@ DataNode *DataNode::newChild(const char *name_in, DataNode *otherNode) {
|
||||
}
|
||||
|
||||
DataNode *DataNode::newChildCloneFrom(const char *name_in, DataNode *cloneFrom) {
|
||||
DataNode *cloneNode = new DataNode(name_in, *cloneFrom->element());
|
||||
auto *cloneNode = new DataNode(name_in, *cloneFrom->element());
|
||||
|
||||
children.push_back(cloneNode);
|
||||
childmap[name_in].push_back(children.back());
|
||||
@ -309,13 +302,9 @@ DataTree::DataTree(const char *name_in) {
|
||||
dn_root.setName(name_in);
|
||||
}
|
||||
|
||||
DataTree::DataTree() {
|
||||
DataTree::DataTree() = default;
|
||||
|
||||
}
|
||||
|
||||
DataTree::~DataTree() {
|
||||
}
|
||||
;
|
||||
DataTree::~DataTree() = default;
|
||||
|
||||
DataNode *DataTree::rootNode() {
|
||||
return &dn_root;
|
||||
@ -342,8 +331,8 @@ string DataTree::wsEncode(const wstring& wstr) {
|
||||
|
||||
encStream << std::hex;
|
||||
|
||||
for(auto i = byte_str.begin(); i != byte_str.end(); i++) {
|
||||
encStream << '%' << setfill('0') << (unsigned int)((unsigned char)(*i));
|
||||
for(char & i : byte_str) {
|
||||
encStream << '%' << setfill('0') << (unsigned int)((unsigned char)i);
|
||||
}
|
||||
|
||||
return encStream.str();
|
||||
@ -366,7 +355,7 @@ wstring DataTree::wsDecode(const string& str) {
|
||||
size_t maxLen = decStr.length();
|
||||
|
||||
//wchar_t is typically 16 bits on windows, and 32 bits on Unix, so use sizeof(wchar_t) everywhere.
|
||||
wchar_t *wc_str = (wchar_t *) ::calloc(maxLen + 1, sizeof(wchar_t));
|
||||
auto *wc_str = (wchar_t *) ::calloc(maxLen + 1, sizeof(wchar_t));
|
||||
|
||||
while (!decStream.eof()) {
|
||||
decStream >> std::hex >> x;
|
||||
@ -589,7 +578,7 @@ void DataTree::setFromXML(DataNode *elem, TiXmlNode *elxml, bool root_node, DT_F
|
||||
if (elxml->FirstChild()->Value() == TIXML_STRING("str")) {
|
||||
std::vector<std::string> tmp_strvect;
|
||||
|
||||
for (pChild = elxml->FirstChild(); pChild != 0; pChild = pChild->NextSibling()) {
|
||||
for (pChild = elxml->FirstChild(); pChild != nullptr; pChild = pChild->NextSibling()) {
|
||||
if (pChild->Value() == TIXML_STRING("str")) {
|
||||
if (!pChild->FirstChild()) {
|
||||
tmp_strvect.push_back("");
|
||||
@ -612,7 +601,7 @@ void DataTree::setFromXML(DataNode *elem, TiXmlNode *elxml, bool root_node, DT_F
|
||||
}
|
||||
}
|
||||
|
||||
for (pChild = elxml->FirstChild(); pChild != 0; pChild = pChild->NextSibling()) {
|
||||
for (pChild = elxml->FirstChild(); pChild != nullptr; pChild = pChild->NextSibling()) {
|
||||
setFromXML(elem, pChild, false, fpp);
|
||||
}
|
||||
|
||||
@ -678,7 +667,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
|
||||
if (nodeName.substr(0, 1) == string("@")) {
|
||||
elxml->SetAttribute(nodeName.substr(1).c_str(), tmp_pstr_as_string.c_str()); //the c_str take care of adding a null erminated character...
|
||||
delete element;
|
||||
element = NULL;
|
||||
element = nullptr;
|
||||
} else {
|
||||
text = new TiXmlText(tmp_pstr_as_string.c_str());
|
||||
element->LinkEndChild(text);
|
||||
@ -779,7 +768,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
|
||||
if (nodeName.substr(0, 1) == string("@")) {
|
||||
elxml->SetAttribute(nodeName.substr(1).c_str(), tmp.c_str());
|
||||
delete element;
|
||||
element = NULL;
|
||||
element = nullptr;
|
||||
} else {
|
||||
text = new TiXmlText(tmp.c_str());
|
||||
element->LinkEndChild(text);
|
||||
@ -791,7 +780,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
|
||||
if (nodeName.substr(0, 1) == string("@")) {
|
||||
elxml->SetAttribute(nodeName.substr(1).c_str(), tmp.c_str());
|
||||
delete element;
|
||||
element = NULL;
|
||||
element = nullptr;
|
||||
} else {
|
||||
text = new TiXmlText(tmp.c_str());
|
||||
element->LinkEndChild(text);
|
||||
@ -802,7 +791,7 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
|
||||
|
||||
tmp_stream.str("");
|
||||
|
||||
for (auto single_string : tmp_stringvect) {
|
||||
for (const auto& single_string : tmp_stringvect) {
|
||||
tmp_node = new TiXmlElement("str");
|
||||
text = new TiXmlText(single_string.c_str());
|
||||
tmp_node->LinkEndChild(text);
|
||||
@ -964,14 +953,14 @@ void DataTree::nodeToXML(DataNode *elem, TiXmlElement *elxml) {
|
||||
void DataTree::printXML() /* get serialized size + return node names header */
|
||||
{
|
||||
TiXmlDocument doc;
|
||||
TiXmlDeclaration * decl = new TiXmlDeclaration("1.0", "", "");
|
||||
auto * decl = new TiXmlDeclaration("1.0", "", "");
|
||||
doc.LinkEndChild(decl);
|
||||
|
||||
DataNode *root = rootNode();
|
||||
|
||||
string rootName = root->getName();
|
||||
|
||||
TiXmlElement *element = new TiXmlElement(rootName.empty() ? "root" : rootName.c_str());
|
||||
auto *element = new TiXmlElement(rootName.empty() ? "root" : rootName.c_str());
|
||||
doc.LinkEndChild(element);
|
||||
|
||||
if (!root->numChildren())
|
||||
@ -1079,12 +1068,12 @@ bool DataTree::LoadFromFileXML(const std::string& filename, DT_FloatingPointPoli
|
||||
|
||||
bool DataTree::SaveToFileXML(const std::string& filename) {
|
||||
TiXmlDocument doc;
|
||||
TiXmlDeclaration * decl = new TiXmlDeclaration("1.0", "", "");
|
||||
auto * decl = new TiXmlDeclaration("1.0", "", "");
|
||||
doc.LinkEndChild(decl);
|
||||
|
||||
string rootName = rootNode()->getName();
|
||||
|
||||
TiXmlElement *element = new TiXmlElement(rootName.empty() ? "root" : rootName.c_str());
|
||||
auto *element = new TiXmlElement(rootName.empty() ? "root" : rootName.c_str());
|
||||
|
||||
doc.LinkEndChild(element);
|
||||
|
||||
|
@ -48,29 +48,29 @@ struct string_less
|
||||
|
||||
|
||||
/* Data Exceptions */
|
||||
class DataException
|
||||
class DataException : public exception
|
||||
{
|
||||
private:
|
||||
string reason;
|
||||
|
||||
public:
|
||||
DataException(const char *why) : reason(why) {}
|
||||
string what() { return reason; }
|
||||
operator string() { return reason; }
|
||||
explicit DataException(const char *why) : reason(why) {}
|
||||
const char* what() const noexcept override { return reason.c_str(); }
|
||||
explicit operator string() { return reason; }
|
||||
};
|
||||
|
||||
|
||||
class DataTypeMismatchException : public DataException
|
||||
{
|
||||
public:
|
||||
DataTypeMismatchException(const char *why) : DataException(why) { }
|
||||
explicit DataTypeMismatchException(const char *why) : DataException(why) { }
|
||||
};
|
||||
|
||||
|
||||
class DataInvalidChildException : public DataException
|
||||
{
|
||||
public:
|
||||
DataInvalidChildException(const char *why) : DataException(why) { }
|
||||
explicit DataInvalidChildException(const char *why) : DataException(why) { }
|
||||
};
|
||||
|
||||
|
||||
@ -206,7 +206,7 @@ public:
|
||||
int unit_size = sizeof(T);
|
||||
//copy in a temporary variable (needed ?)
|
||||
T local_copy = scalar_in;
|
||||
unsigned char* local_copy_ptr = reinterpret_cast<unsigned char*>(&local_copy);
|
||||
auto* local_copy_ptr = reinterpret_cast<unsigned char*>(&local_copy);
|
||||
|
||||
data_val.assign(local_copy_ptr, local_copy_ptr + unit_size);
|
||||
}
|
||||
@ -227,7 +227,7 @@ public:
|
||||
|
||||
//copy in a temporary variable (needed ?)
|
||||
T local_copy = single_element;
|
||||
unsigned char* local_copy_ptr = reinterpret_cast<unsigned char*>(&local_copy);
|
||||
auto* local_copy_ptr = reinterpret_cast<unsigned char*>(&local_copy);
|
||||
|
||||
single_buffer.assign(local_copy_ptr, local_copy_ptr + unit_size);
|
||||
|
||||
@ -308,7 +308,7 @@ public:
|
||||
scalar_out = T(*storage_ptr);
|
||||
|
||||
} else if (storageType == DATA_UCHAR) {
|
||||
unsigned char* storage_ptr = reinterpret_cast<unsigned char*>(&data_val[0]);
|
||||
auto* storage_ptr = reinterpret_cast<unsigned char*>(&data_val[0]);
|
||||
//constructor-like
|
||||
scalar_out = T(*storage_ptr);
|
||||
} else if (storageType == DATA_INT) {
|
||||
@ -316,7 +316,7 @@ public:
|
||||
//constructor-like
|
||||
scalar_out = T(*storage_ptr);
|
||||
} else if (storageType == DATA_UINT) {
|
||||
unsigned int* storage_ptr = reinterpret_cast<unsigned int*>(&data_val[0]);
|
||||
auto* storage_ptr = reinterpret_cast<unsigned int*>(&data_val[0]);
|
||||
//constructor-like
|
||||
scalar_out = T(*storage_ptr);
|
||||
} else if (storageType == DATA_LONG) {
|
||||
@ -324,19 +324,19 @@ public:
|
||||
//constructor-like
|
||||
scalar_out = T(*storage_ptr);
|
||||
} else if (storageType == DATA_ULONG) {
|
||||
unsigned long* storage_ptr = reinterpret_cast<unsigned long*>(&data_val[0]);
|
||||
auto* storage_ptr = reinterpret_cast<unsigned long*>(&data_val[0]);
|
||||
//constructor-like
|
||||
scalar_out = T(*storage_ptr);
|
||||
} else if (storageType == DATA_LONGLONG) {
|
||||
long long* storage_ptr = reinterpret_cast<long long*>(&data_val[0]);
|
||||
auto* storage_ptr = reinterpret_cast<long long*>(&data_val[0]);
|
||||
//constructor-like
|
||||
scalar_out = T(*storage_ptr);
|
||||
} else if (storageType == DATA_FLOAT) {
|
||||
float* storage_ptr = reinterpret_cast<float*>(&data_val[0]);
|
||||
auto* storage_ptr = reinterpret_cast<float*>(&data_val[0]);
|
||||
//constructor-like
|
||||
scalar_out = T(*storage_ptr);
|
||||
} else if (storageType == DATA_DOUBLE) {
|
||||
double* storage_ptr = reinterpret_cast<double*>(&data_val[0]);
|
||||
auto* storage_ptr = reinterpret_cast<double*>(&data_val[0]);
|
||||
//constructor-like
|
||||
scalar_out = T(*storage_ptr);
|
||||
}
|
||||
@ -367,7 +367,7 @@ public:
|
||||
scalar_out = T(*storage_ptr);
|
||||
|
||||
} else if (storageType == DATA_UCHAR_VECTOR) {
|
||||
unsigned char* storage_ptr = reinterpret_cast<unsigned char*>(&single_storage_element[0]);
|
||||
auto* storage_ptr = reinterpret_cast<unsigned char*>(&single_storage_element[0]);
|
||||
//constructor-like
|
||||
scalar_out = T(*storage_ptr);
|
||||
} else if (storageType == DATA_INT_VECTOR) {
|
||||
@ -375,7 +375,7 @@ public:
|
||||
//constructor-like
|
||||
scalar_out = T(*storage_ptr);
|
||||
} else if (storageType == DATA_UINT_VECTOR) {
|
||||
unsigned int* storage_ptr = reinterpret_cast<unsigned int*>(&single_storage_element[0]);
|
||||
auto* storage_ptr = reinterpret_cast<unsigned int*>(&single_storage_element[0]);
|
||||
//constructor-like
|
||||
scalar_out = T(*storage_ptr);
|
||||
} else if (storageType == DATA_LONG_VECTOR) {
|
||||
@ -383,19 +383,19 @@ public:
|
||||
//constructor-like
|
||||
scalar_out = T(*storage_ptr);
|
||||
} else if (storageType == DATA_ULONG_VECTOR) {
|
||||
unsigned long* storage_ptr = reinterpret_cast<unsigned long*>(&single_storage_element[0]);
|
||||
auto* storage_ptr = reinterpret_cast<unsigned long*>(&single_storage_element[0]);
|
||||
//constructor-like
|
||||
scalar_out = T(*storage_ptr);
|
||||
} else if (storageType == DATA_LONGLONG_VECTOR) {
|
||||
long long* storage_ptr = reinterpret_cast<long long*>(&single_storage_element[0]);
|
||||
auto* storage_ptr = reinterpret_cast<long long*>(&single_storage_element[0]);
|
||||
//constructor-like
|
||||
scalar_out = T(*storage_ptr);
|
||||
} else if (storageType == DATA_FLOAT_VECTOR) {
|
||||
float* storage_ptr = reinterpret_cast<float*>(&single_storage_element[0]);
|
||||
auto* storage_ptr = reinterpret_cast<float*>(&single_storage_element[0]);
|
||||
//constructor-like
|
||||
scalar_out = T(*storage_ptr);
|
||||
} else if (storageType == DATA_DOUBLE_VECTOR) {
|
||||
double* storage_ptr = reinterpret_cast<double*>(&single_storage_element[0]);
|
||||
auto* storage_ptr = reinterpret_cast<double*>(&single_storage_element[0]);
|
||||
//constructor-like
|
||||
scalar_out = T(*storage_ptr);
|
||||
}
|
||||
@ -450,7 +450,7 @@ public:
|
||||
size_t maxNbWchars = getDataSize() / sizeof(wchar_t);
|
||||
|
||||
//be paranoid, zero the buffer
|
||||
wchar_t *tmp_wstr = (wchar_t *)::calloc(maxNbWchars + 1, sizeof(wchar_t));
|
||||
auto *tmp_wstr = (wchar_t *)::calloc(maxNbWchars + 1, sizeof(wchar_t));
|
||||
|
||||
//the last wchar_t is actually zero if anything goes wrong...
|
||||
::mbstowcs(tmp_wstr, (const char*)&data_val[0], maxNbWchars);
|
||||
@ -516,7 +516,7 @@ private:
|
||||
|
||||
public:
|
||||
DataNode();
|
||||
DataNode(const char *name_in);
|
||||
explicit DataNode(const char *name_in);
|
||||
DataNode(const char *name_in, DataElement &cloneFrom);
|
||||
DataNode(const char *name_in, DataNode &cloneFrom);
|
||||
|
||||
@ -550,26 +550,26 @@ public:
|
||||
|
||||
void findAll(const char *name_in, vector<DataNode *> &node_list_out);
|
||||
|
||||
// operator string () { string s; element()->get(s); return s; }
|
||||
operator const char * () { if (element()->getDataType() == DataElement::DATA_STRING) { return element()->getDataPointer(); } else { return NULL; } }
|
||||
operator char () { char v; element()->get(v); return v; }
|
||||
operator unsigned char () { unsigned char v; element()->get(v); return v; }
|
||||
operator int () { int v; element()->get(v); return v; }
|
||||
operator unsigned int () { unsigned int v; element()->get(v); return v; }
|
||||
operator long () { long v; element()->get(v); return v; }
|
||||
operator unsigned long () { unsigned long v; element()->get(v); return v; }
|
||||
operator long long () { long long v; element()->get(v); return v; }
|
||||
operator float () { float v; element()->get(v); return v; }
|
||||
operator double () { double v; element()->get(v); return v; }
|
||||
explicit operator string () { string s; element()->get(s); return s; }
|
||||
explicit operator const char * () { if (element()->getDataType() == DataElement::DATA_STRING) { return element()->getDataPointer(); } else { return nullptr; } }
|
||||
explicit operator char () { char v=0; element()->get(v); return v; }
|
||||
explicit operator unsigned char () { unsigned char v=0; element()->get(v); return v; }
|
||||
explicit operator int () { int v=0; element()->get(v); return v; }
|
||||
explicit operator unsigned int () { unsigned int v=0; element()->get(v); return v; }
|
||||
explicit operator long () { long v=0; element()->get(v); return v; }
|
||||
explicit operator unsigned long () { unsigned long v=0; element()->get(v); return v; }
|
||||
explicit operator long long () { long long v=0; element()->get(v); return v; }
|
||||
explicit operator float () { float v=0; element()->get(v); return v; }
|
||||
explicit operator double () { double v=0; element()->get(v); return v; }
|
||||
|
||||
operator vector<char> () { vector<char> v; element()->get(v); return v; }
|
||||
operator vector<unsigned char> () { vector<unsigned char> v; element()->get(v); return v; }
|
||||
operator vector<int> () { vector<int> v; element()->get(v); return v; }
|
||||
operator vector<unsigned int> () { vector<unsigned int> v; element()->get(v); return v; }
|
||||
operator vector<long> () { vector<long> v; element()->get(v); return v; }
|
||||
operator vector<unsigned long> () { vector<unsigned long> v; element()->get(v); return v; }
|
||||
operator vector<float> () { vector<float> v; element()->get(v); return v; }
|
||||
operator vector<double> () { vector<double> v; element()->get(v); return v; }
|
||||
explicit operator vector<char> () { vector<char> v; element()->get(v); return v; }
|
||||
explicit operator vector<unsigned char> () { vector<unsigned char> v; element()->get(v); return v; }
|
||||
explicit operator vector<int> () { vector<int> v; element()->get(v); return v; }
|
||||
explicit operator vector<unsigned int> () { vector<unsigned int> v; element()->get(v); return v; }
|
||||
explicit operator vector<long> () { vector<long> v; element()->get(v); return v; }
|
||||
explicit operator vector<unsigned long> () { vector<unsigned long> v; element()->get(v); return v; }
|
||||
explicit operator vector<float> () { vector<float> v; element()->get(v); return v; }
|
||||
explicit operator vector<double> () { vector<double> v; element()->get(v); return v; }
|
||||
|
||||
const string &operator= (const string &s) { element()->set(s); return s; }
|
||||
const wstring &operator= (const wstring &s) { element()->set(s); return s; }
|
||||
@ -619,7 +619,7 @@ private:
|
||||
wstring wsDecode(const string& str);
|
||||
|
||||
public:
|
||||
DataTree(const char *name_in);
|
||||
explicit DataTree(const char *name_in);
|
||||
DataTree();
|
||||
~DataTree();
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
|
||||
#include "GLExt.h"
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
#ifdef __APPLE__
|
||||
@ -64,10 +63,10 @@ void initGLExtensions() {
|
||||
#if defined(__linux__) || defined(__FreeBSD__)
|
||||
dlopen("libglx.so",RTLD_LAZY);
|
||||
|
||||
void (*glxSwapIntervalEXTFunc) (Display *dpy, GLXDrawable drawable, int interval) = 0;
|
||||
int (*glxSwapIntervalMESAFunc)(unsigned int interval) = 0;
|
||||
int (*glxSwapIntervalSGIFunc) (int interval) = 0;
|
||||
void (*DRI2SwapIntervalFunc) (Display *dpy, XID drawable, int interval) = 0;
|
||||
void (*glxSwapIntervalEXTFunc) (Display *dpy, GLXDrawable drawable, int interval) = nullptr;
|
||||
int (*glxSwapIntervalMESAFunc)(unsigned int interval) = nullptr;
|
||||
int (*glxSwapIntervalSGIFunc) (int interval) = nullptr;
|
||||
void (*DRI2SwapIntervalFunc) (Display *dpy, XID drawable, int interval) = nullptr;
|
||||
|
||||
glxSwapIntervalEXTFunc = (void (*) (Display *dpy, GLXDrawable drawable, int interval)) dlsym(RTLD_DEFAULT,"glXSwapIntervalEXT");
|
||||
glxSwapIntervalMESAFunc = (int (*)(unsigned int interval)) dlsym(RTLD_DEFAULT,"glXSwapIntervalMESA");
|
||||
@ -75,10 +74,10 @@ void initGLExtensions() {
|
||||
DRI2SwapIntervalFunc = (void (*) (Display *dpy, XID drawable, int interval)) dlsym(RTLD_DEFAULT,"DRI2SwapInterval");
|
||||
|
||||
std::cout << "Available vertical sync SwapInterval functions: " << std::endl;
|
||||
std::cout << "\tglxSwapIntervalEXT: " << ((glxSwapIntervalEXTFunc != 0)?"Yes":"No") << std::endl;
|
||||
std::cout << "\tDRI2SwapInterval: " << ((DRI2SwapIntervalFunc != 0)?"Yes":"No") << std::endl;
|
||||
std::cout << "\tglxSwapIntervalMESA: " << ((glxSwapIntervalMESAFunc != 0)?"Yes":"No") << std::endl;
|
||||
std::cout << "\tglxSwapIntervalSGI: " << ((glxSwapIntervalSGIFunc != 0)?"Yes":"No") << std::endl;
|
||||
std::cout << "\tglxSwapIntervalEXT: " << ((glxSwapIntervalEXTFunc != nullptr)?"Yes":"No") << std::endl;
|
||||
std::cout << "\tDRI2SwapInterval: " << ((DRI2SwapIntervalFunc != nullptr)?"Yes":"No") << std::endl;
|
||||
std::cout << "\tglxSwapIntervalMESA: " << ((glxSwapIntervalMESAFunc != nullptr)?"Yes":"No") << std::endl;
|
||||
std::cout << "\tglxSwapIntervalSGI: " << ((glxSwapIntervalSGIFunc != nullptr)?"Yes":"No") << std::endl;
|
||||
|
||||
if (glxSwapIntervalEXTFunc) {
|
||||
Display *dpy = glXGetCurrentDisplay();
|
||||
|
@ -54,15 +54,13 @@ GLFontChar::GLFontChar() :
|
||||
|
||||
}
|
||||
|
||||
GLFontChar::~GLFontChar() {
|
||||
|
||||
}
|
||||
GLFontChar::~GLFontChar() = default;
|
||||
|
||||
void GLFontChar::setId(int idval) {
|
||||
id = idval;
|
||||
}
|
||||
|
||||
int GLFontChar::getId() {
|
||||
int GLFontChar::getId() const {
|
||||
return id;
|
||||
}
|
||||
|
||||
@ -116,7 +114,7 @@ void GLFontChar::setHeight(int h) {
|
||||
}
|
||||
}
|
||||
|
||||
int GLFontChar::getHeight() {
|
||||
int GLFontChar::getHeight() const {
|
||||
return height;
|
||||
}
|
||||
|
||||
@ -128,7 +126,7 @@ int GLFontChar::getXAdvance() {
|
||||
return xadvance;
|
||||
}
|
||||
|
||||
float GLFontChar::getAspect() {
|
||||
float GLFontChar::getAspect() const {
|
||||
return aspect;
|
||||
}
|
||||
|
||||
@ -136,7 +134,7 @@ void GLFontChar::setIndex(unsigned int idx) {
|
||||
index = idx;
|
||||
}
|
||||
|
||||
int GLFontChar::getIndex() {
|
||||
int GLFontChar::getIndex() const {
|
||||
return index;
|
||||
}
|
||||
|
||||
@ -148,9 +146,7 @@ GLFont::GLFont(GLFontSize size, std::wstring defFileName):
|
||||
fontDefFileSource = defFileName;
|
||||
}
|
||||
|
||||
GLFont::~GLFont() {
|
||||
|
||||
}
|
||||
GLFont::~GLFont() = default;
|
||||
|
||||
std::wstring GLFont::nextParam(std::wistringstream &str) {
|
||||
std::wstring param_str;
|
||||
@ -171,7 +167,7 @@ std::wstring GLFont::nextParam(std::wistringstream &str) {
|
||||
std::wstring GLFont::getParamKey(const std::wstring& param_str) {
|
||||
std::wstring keyName;
|
||||
|
||||
size_t eqpos = param_str.find(L"=");
|
||||
size_t eqpos = param_str.find(L'=');
|
||||
|
||||
if (eqpos != std::wstring::npos) {
|
||||
keyName = param_str.substr(0, eqpos);
|
||||
@ -183,7 +179,7 @@ std::wstring GLFont::getParamKey(const std::wstring& param_str) {
|
||||
std::wstring GLFont::getParamValue(const std::wstring& param_str) {
|
||||
std::wstring value;
|
||||
|
||||
size_t eqpos = param_str.find(L"=");
|
||||
size_t eqpos = param_str.find(L'=');
|
||||
|
||||
if (eqpos != std::wstring::npos) {
|
||||
value = param_str.substr(eqpos + 1);
|
||||
@ -334,7 +330,7 @@ void GLFont::loadFontOnce() {
|
||||
getline(input, char_param_str);
|
||||
std::wistringstream char_param(char_param_str);
|
||||
|
||||
GLFontChar *newChar = new GLFontChar;
|
||||
auto *newChar = new GLFontChar;
|
||||
|
||||
while (!char_param.eof()) {
|
||||
std::wstring param = nextParam(char_param);
|
||||
@ -381,7 +377,7 @@ void GLFont::loadFontOnce() {
|
||||
}
|
||||
}
|
||||
|
||||
if (imageFile != "" && imageWidth && imageHeight && characters.size()) {
|
||||
if (!imageFile.empty() && imageWidth && imageHeight && !characters.empty()) {
|
||||
|
||||
// Load file and decode image.
|
||||
std::vector<unsigned char> image;
|
||||
@ -393,7 +389,7 @@ void GLFont::loadFontOnce() {
|
||||
|
||||
int png_size = png_file.Length();
|
||||
|
||||
unsigned char* raw_image = new unsigned char[png_size];
|
||||
auto* raw_image = new unsigned char[png_size];
|
||||
|
||||
if (png_size > 0) {
|
||||
|
||||
@ -482,9 +478,7 @@ float GLFont::getStringWidth(const std::wstring& str, float size, float viewAspe
|
||||
|
||||
float width = 0;
|
||||
|
||||
for (int i = 0, iMax = str.length(); i < iMax; i++) {
|
||||
int charId = str.at(i);
|
||||
|
||||
for (int charId : str) {
|
||||
if (characters.find(charId) == characters.end()) {
|
||||
continue;
|
||||
}
|
||||
@ -599,9 +593,7 @@ void GLFont::drawString(const std::wstring& str, int pxHeight, float xpos, float
|
||||
glVertexPointer(2, GL_FLOAT, 0, &gl_vertices[0]);
|
||||
glTexCoordPointer(2, GL_FLOAT, 0, &gl_uv[0]);
|
||||
|
||||
for (int i = 0, iMax = str.length(); i < iMax; i++) {
|
||||
int charId = str.at(i);
|
||||
|
||||
for (int charId : str) {
|
||||
if (characters.find(charId) == characters.end()) {
|
||||
continue;
|
||||
}
|
||||
@ -644,7 +636,7 @@ void GLFont::drawString(const std::string& str, int pxHeight, float xpos, float
|
||||
}
|
||||
|
||||
// Draw cached GLFontCacheString
|
||||
void GLFont::drawCacheString(GLFontStringCache *fc, float xpos, float ypos, Align hAlign, Align vAlign) {
|
||||
void GLFont::drawCacheString(GLFontStringCache *fc, float xpos, float ypos, Align hAlign, Align vAlign) const {
|
||||
|
||||
float size = (float) fc->pxHeight / (float) fc->vpy;
|
||||
|
||||
@ -701,7 +693,7 @@ void GLFont::drawCacheString(GLFontStringCache *fc, float xpos, float ypos, Alig
|
||||
// Compile optimized GLFontCacheString
|
||||
GLFontStringCache *GLFont::cacheString(const std::wstring& str, int pxHeight, int vpx, int vpy) {
|
||||
|
||||
GLFontStringCache *fc = new GLFontStringCache;
|
||||
auto *fc = new GLFontStringCache;
|
||||
|
||||
fc->pxHeight = pxHeight;
|
||||
fc->vpx = vpx;
|
||||
@ -713,9 +705,7 @@ GLFontStringCache *GLFont::cacheString(const std::wstring& str, int pxHeight, in
|
||||
fc->msgWidth = getStringWidth(str, size, viewAspect);
|
||||
|
||||
int nChar = 0;
|
||||
for (int i = 0, iMax = str.length(); i < iMax; i++) {
|
||||
int charId = str.at(i);
|
||||
|
||||
for (int charId : str) {
|
||||
if (characters.find(charId) == characters.end()) {
|
||||
continue;
|
||||
}
|
||||
@ -730,9 +720,7 @@ GLFontStringCache *GLFont::cacheString(const std::wstring& str, int pxHeight, in
|
||||
CubicVR::mat4 trans = CubicVR::mat4::scale(size / viewAspect, size, 1.0f);
|
||||
|
||||
int c = 0;
|
||||
for (int i = 0, iMax = str.length(); i < iMax; i++) {
|
||||
int charId = str.at(i);
|
||||
|
||||
for (int charId : str) {
|
||||
if (characters.find(charId) == characters.end()) {
|
||||
continue;
|
||||
}
|
||||
@ -915,7 +903,7 @@ GLFont::Drawer::Drawer(int basicFontSize, double scaleFactor) {
|
||||
renderingFontScaleFactor = (double) targetSize / rawSize;
|
||||
}
|
||||
|
||||
void GLFont::Drawer::drawString(const std::wstring& str, float xpos, float ypos, Align hAlign, Align vAlign, int vpx, int vpy, bool cacheable) {
|
||||
void GLFont::Drawer::drawString(const std::wstring& str, float xpos, float ypos, Align hAlign, Align vAlign, int vpx, int vpy, bool cacheable) const {
|
||||
|
||||
GLFont& appliedFont = fonts[renderingFontIndex];
|
||||
|
||||
@ -923,7 +911,7 @@ void GLFont::Drawer::drawString(const std::wstring& str, float xpos, float ypos,
|
||||
}
|
||||
|
||||
//Public drawing font, 8 bit char version.
|
||||
void GLFont::Drawer::drawString(const std::string& str, float xpos, float ypos, Align hAlign, Align vAlign, int vpx, int vpy, bool cacheable) {
|
||||
void GLFont::Drawer::drawString(const std::string& str, float xpos, float ypos, Align hAlign, Align vAlign, int vpx, int vpy, bool cacheable) const {
|
||||
|
||||
GLFont& appliedFont = fonts[renderingFontIndex];
|
||||
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
void setId(int idval);
|
||||
|
||||
// Returns the code point of the 16bit character, supposely Unicode.
|
||||
int getId();
|
||||
int getId() const;
|
||||
|
||||
void setXOffset(int xofs);
|
||||
int getXOffset();
|
||||
@ -53,15 +53,15 @@ public:
|
||||
int getWidth();
|
||||
|
||||
void setHeight(int h);
|
||||
int getHeight();
|
||||
int getHeight() const;
|
||||
|
||||
void setXAdvance(int xadv);
|
||||
int getXAdvance();
|
||||
|
||||
float getAspect();
|
||||
float getAspect() const;
|
||||
|
||||
void setIndex(unsigned int idx);
|
||||
int getIndex();
|
||||
int getIndex() const;
|
||||
|
||||
private:
|
||||
// this is the code point of the 16bit character, supposly Unicode.
|
||||
@ -140,7 +140,7 @@ private:
|
||||
void drawString(const std::string& str, int pxHeight, float xpos, float ypos, Align hAlign = GLFONT_ALIGN_LEFT, Align vAlign = GLFONT_ALIGN_TOP, int vpx = 0, int vpy = 0, bool cacheable = false);
|
||||
|
||||
GLFontStringCache *cacheString(const std::wstring& str, int pxHeight, int vpx, int vpy);
|
||||
void drawCacheString(GLFontStringCache *fc, float xpos, float ypos, Align hAlign, Align vAlign);
|
||||
void drawCacheString(GLFontStringCache *fc, float xpos, float ypos, Align hAlign, Align vAlign) const;
|
||||
|
||||
void doCacheGC();
|
||||
void clearCache();
|
||||
@ -195,10 +195,10 @@ public:
|
||||
Drawer(int basicFontSize, double scaleFactor);
|
||||
|
||||
//Public drawing font, 16 bit char version.
|
||||
void drawString(const std::wstring& str, float xpos, float ypos, Align hAlign = GLFONT_ALIGN_LEFT, Align vAlign = GLFONT_ALIGN_TOP, int vpx = 0, int vpy = 0, bool cacheable = false);
|
||||
void drawString(const std::wstring& str, float xpos, float ypos, Align hAlign = GLFONT_ALIGN_LEFT, Align vAlign = GLFONT_ALIGN_TOP, int vpx = 0, int vpy = 0, bool cacheable = false) const;
|
||||
|
||||
//Public drawing font, 8 bit char version.
|
||||
void drawString(const std::string& str, float xpos, float ypos, Align hAlign = GLFONT_ALIGN_LEFT, Align vAlign = GLFONT_ALIGN_TOP, int vpx = 0, int vpy = 0, bool cacheable = false);
|
||||
void drawString(const std::string& str, float xpos, float ypos, Align hAlign = GLFONT_ALIGN_LEFT, Align vAlign = GLFONT_ALIGN_TOP, int vpx = 0, int vpy = 0, bool cacheable = false) const;
|
||||
|
||||
}; //end class Drawer
|
||||
|
||||
|
@ -2,11 +2,9 @@
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
|
||||
#include "Gradient.h"
|
||||
#include <stddef.h>
|
||||
#include <cstddef>
|
||||
|
||||
Gradient::Gradient() {
|
||||
//nothing
|
||||
}
|
||||
Gradient::Gradient() = default;
|
||||
|
||||
void Gradient::clear() {
|
||||
colors.clear();
|
||||
@ -86,6 +84,4 @@ void Gradient::generate(unsigned int len) {
|
||||
}
|
||||
}
|
||||
|
||||
Gradient::~Gradient() {
|
||||
|
||||
}
|
||||
Gradient::~Gradient() = default;
|
||||
|
@ -2,7 +2,6 @@
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
|
||||
#include "MouseTracker.h"
|
||||
#include <iostream>
|
||||
|
||||
MouseTracker::MouseTracker(wxWindow *target) :
|
||||
mouseX(0), mouseY(0), lastMouseX(0), lastMouseY(0), originMouseX(0), originMouseY(0), deltaMouseX(0), deltaMouseY(0), vertDragLock(false), horizDragLock(
|
||||
@ -11,12 +10,12 @@ MouseTracker::MouseTracker(wxWindow *target) :
|
||||
}
|
||||
|
||||
MouseTracker::MouseTracker() :
|
||||
MouseTracker(NULL) {
|
||||
MouseTracker(nullptr) {
|
||||
|
||||
}
|
||||
|
||||
void MouseTracker::OnMouseMoved(wxMouseEvent& event) {
|
||||
if (target == NULL) {
|
||||
if (target == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -55,7 +54,7 @@ void MouseTracker::OnMouseWheelMoved(wxMouseEvent& /* event */) {
|
||||
}
|
||||
|
||||
void MouseTracker::OnMouseDown(wxMouseEvent& event) {
|
||||
if (isMouseRightDown || target == NULL) {
|
||||
if (isMouseRightDown || target == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -75,7 +74,7 @@ void MouseTracker::OnMouseReleased(wxMouseEvent& /* event */) {
|
||||
}
|
||||
|
||||
void MouseTracker::OnMouseRightDown(wxMouseEvent& event) {
|
||||
if (isMouseDown || target == NULL) {
|
||||
if (isMouseDown || target == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -106,47 +105,47 @@ void MouseTracker::OnMouseLeftWindow(wxMouseEvent& /* event */) {
|
||||
isMouseInView = false;
|
||||
}
|
||||
|
||||
float MouseTracker::getOriginMouseX() {
|
||||
float MouseTracker::getOriginMouseX() const {
|
||||
return originMouseX;
|
||||
}
|
||||
|
||||
float MouseTracker::getOriginMouseY() {
|
||||
float MouseTracker::getOriginMouseY() const {
|
||||
return originMouseY;
|
||||
}
|
||||
|
||||
float MouseTracker::getOriginDeltaMouseX() {
|
||||
float MouseTracker::getOriginDeltaMouseX() const {
|
||||
return mouseX - originMouseX;
|
||||
}
|
||||
|
||||
float MouseTracker::getOriginDeltaMouseY() {
|
||||
float MouseTracker::getOriginDeltaMouseY() const {
|
||||
return mouseY - originMouseY;
|
||||
}
|
||||
|
||||
float MouseTracker::getDeltaMouseX() {
|
||||
float MouseTracker::getDeltaMouseX() const {
|
||||
return deltaMouseX;
|
||||
}
|
||||
|
||||
float MouseTracker::getDeltaMouseY() {
|
||||
float MouseTracker::getDeltaMouseY() const {
|
||||
return deltaMouseY;
|
||||
}
|
||||
|
||||
float MouseTracker::getLastMouseX() {
|
||||
float MouseTracker::getLastMouseX() const {
|
||||
return lastMouseX;
|
||||
}
|
||||
|
||||
float MouseTracker::getLastMouseY() {
|
||||
float MouseTracker::getLastMouseY() const {
|
||||
return lastMouseY;
|
||||
}
|
||||
|
||||
CubicVR::vec2 MouseTracker::getGLXY() {
|
||||
CubicVR::vec2 MouseTracker::getGLXY() const {
|
||||
return CubicVR::vec2((getMouseX()-0.5)*2.0, (getMouseY()-0.5)*2.0);
|
||||
}
|
||||
|
||||
float MouseTracker::getMouseX() {
|
||||
float MouseTracker::getMouseX() const {
|
||||
return mouseX;
|
||||
}
|
||||
|
||||
float MouseTracker::getMouseY() {
|
||||
float MouseTracker::getMouseY() const {
|
||||
return mouseY;
|
||||
}
|
||||
|
||||
@ -158,19 +157,19 @@ void MouseTracker::setHorizDragLock(bool dragLock) {
|
||||
horizDragLock = dragLock;
|
||||
}
|
||||
|
||||
bool MouseTracker::getVertDragLock() {
|
||||
bool MouseTracker::getVertDragLock() const {
|
||||
return vertDragLock;
|
||||
}
|
||||
|
||||
bool MouseTracker::getHorizDragLock() {
|
||||
bool MouseTracker::getHorizDragLock() const {
|
||||
return horizDragLock;
|
||||
}
|
||||
|
||||
bool MouseTracker::mouseDown() {
|
||||
bool MouseTracker::mouseDown() const {
|
||||
return isMouseDown;
|
||||
}
|
||||
|
||||
bool MouseTracker::mouseInView() {
|
||||
bool MouseTracker::mouseInView() const {
|
||||
return isMouseInView;
|
||||
}
|
||||
|
||||
@ -179,6 +178,6 @@ void MouseTracker::setTarget(wxWindow *target_in) {
|
||||
}
|
||||
|
||||
|
||||
bool MouseTracker::mouseRightDown() {
|
||||
bool MouseTracker::mouseRightDown() const {
|
||||
return isMouseRightDown;
|
||||
}
|
||||
|
@ -20,25 +20,25 @@ public:
|
||||
void OnMouseEnterWindow(wxMouseEvent& event);
|
||||
void OnMouseLeftWindow(wxMouseEvent& event);
|
||||
|
||||
float getOriginMouseX();
|
||||
float getOriginMouseY();
|
||||
float getOriginDeltaMouseX();
|
||||
float getOriginDeltaMouseY();
|
||||
float getDeltaMouseX();
|
||||
float getDeltaMouseY();
|
||||
float getLastMouseX();
|
||||
float getLastMouseY();
|
||||
CubicVR::vec2 getGLXY();
|
||||
float getMouseX();
|
||||
float getMouseY();
|
||||
float getOriginMouseX() const;
|
||||
float getOriginMouseY() const;
|
||||
float getOriginDeltaMouseX() const;
|
||||
float getOriginDeltaMouseY() const;
|
||||
float getDeltaMouseX() const;
|
||||
float getDeltaMouseY() const;
|
||||
float getLastMouseX() const;
|
||||
float getLastMouseY() const;
|
||||
CubicVR::vec2 getGLXY() const;
|
||||
float getMouseX() const;
|
||||
float getMouseY() const;
|
||||
|
||||
void setVertDragLock(bool dragLock);
|
||||
void setHorizDragLock(bool dragLock);
|
||||
bool getVertDragLock();
|
||||
bool getHorizDragLock();
|
||||
bool mouseDown();
|
||||
bool mouseRightDown();
|
||||
bool mouseInView();
|
||||
bool getVertDragLock() const;
|
||||
bool getHorizDragLock() const;
|
||||
bool mouseDown() const;
|
||||
bool mouseRightDown() const;
|
||||
bool mouseInView() const;
|
||||
void setTarget(wxWindow *target_in);
|
||||
|
||||
private:
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
#include <cstdint>
|
||||
#include <stddef.h>
|
||||
#include <cstddef>
|
||||
#include <condition_variable>
|
||||
#include <typeinfo>
|
||||
#include <iostream>
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include <iostream>
|
||||
#include "Timer.h"
|
||||
|
||||
Timer::Timer(void) : time_elapsed(0), system_milliseconds(0), start_time(0), end_time(0), last_update(0), num_updates(0), paused_time(0), offset(0), paused_state(false), lock_state(false), lock_rate(0)
|
||||
Timer::Timer() : time_elapsed(0), system_milliseconds(0), start_time(0), end_time(0), last_update(0), num_updates(0), paused_time(0), offset(0), paused_state(false), lock_state(false), lock_rate(0)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
// According to Microsoft, QueryPerformanceXXX API is perfectly
|
||||
@ -15,7 +15,7 @@ Timer::Timer(void) : time_elapsed(0), system_milliseconds(0), start_time(0), end
|
||||
}
|
||||
|
||||
|
||||
void Timer::start(void)
|
||||
void Timer::start()
|
||||
{
|
||||
update();
|
||||
num_updates = 0;
|
||||
@ -29,13 +29,13 @@ void Timer::start(void)
|
||||
}
|
||||
|
||||
|
||||
void Timer::stop(void)
|
||||
void Timer::stop()
|
||||
{
|
||||
end_time = system_milliseconds;
|
||||
}
|
||||
|
||||
|
||||
void Timer::reset(void)
|
||||
void Timer::reset()
|
||||
{
|
||||
start();
|
||||
}
|
||||
@ -63,12 +63,12 @@ void Timer::unlock()
|
||||
lock_rate = 0;
|
||||
}
|
||||
|
||||
bool Timer::locked()
|
||||
bool Timer::locked() const
|
||||
{
|
||||
return lock_state;
|
||||
}
|
||||
|
||||
void Timer::update(void)
|
||||
void Timer::update()
|
||||
{
|
||||
num_updates++;
|
||||
last_update = system_milliseconds;
|
||||
@ -105,14 +105,14 @@ void Timer::update(void)
|
||||
}
|
||||
|
||||
|
||||
unsigned long Timer::getMilliseconds(void)
|
||||
unsigned long Timer::getMilliseconds() const
|
||||
{
|
||||
return time_elapsed;
|
||||
}
|
||||
|
||||
|
||||
|
||||
double Timer::getSeconds(void)
|
||||
double Timer::getSeconds() const
|
||||
{
|
||||
return ((double)getMilliseconds())/1000.0;
|
||||
}
|
||||
@ -131,30 +131,30 @@ void Timer::setSeconds(double seconds_in)
|
||||
}
|
||||
|
||||
|
||||
double Timer::lastUpdateSeconds(void)
|
||||
double Timer::lastUpdateSeconds() const
|
||||
{
|
||||
return ((double)lastUpdateMilliseconds())/1000.0;
|
||||
}
|
||||
|
||||
|
||||
unsigned long Timer::lastUpdateMilliseconds(void)
|
||||
unsigned long Timer::lastUpdateMilliseconds() const
|
||||
{
|
||||
return system_milliseconds-last_update;
|
||||
}
|
||||
|
||||
unsigned long Timer::totalMilliseconds()
|
||||
unsigned long Timer::totalMilliseconds() const
|
||||
{
|
||||
return system_milliseconds-start_time;
|
||||
}
|
||||
|
||||
|
||||
double Timer::totalSeconds(void)
|
||||
double Timer::totalSeconds() const
|
||||
{
|
||||
return totalMilliseconds()/1000.0;
|
||||
}
|
||||
|
||||
|
||||
unsigned long Timer::getNumUpdates(void)
|
||||
unsigned long Timer::getNumUpdates() const
|
||||
{
|
||||
return num_updates;
|
||||
}
|
||||
@ -165,7 +165,7 @@ void Timer::paused(bool pause_in)
|
||||
paused_state = pause_in;
|
||||
}
|
||||
|
||||
bool Timer::paused()
|
||||
bool Timer::paused() const
|
||||
{
|
||||
return paused_state;
|
||||
}
|
||||
|
@ -47,13 +47,13 @@ public:
|
||||
/**
|
||||
* Resets the timer to 0 and begins timing
|
||||
*/
|
||||
void start(void);
|
||||
void start();
|
||||
|
||||
/// Stop the timer
|
||||
/**
|
||||
* Stops the timer and records the end time
|
||||
*/
|
||||
void stop(void);
|
||||
void stop();
|
||||
|
||||
/// Locks the timer to a specified framerate (for recording / benchmarking purposes typically)
|
||||
/**
|
||||
@ -71,20 +71,20 @@ public:
|
||||
/**
|
||||
* Check locked state
|
||||
*/
|
||||
bool locked();
|
||||
bool locked() const;
|
||||
|
||||
/// Reset the timer counter
|
||||
/**
|
||||
* Resetting the timer will reset the current time to 0
|
||||
*/
|
||||
void reset(void);
|
||||
void reset();
|
||||
|
||||
/// Timer update
|
||||
/**
|
||||
* Calling the update command will bring the timer value up to date, this is meant
|
||||
* to be called at the begining of the frame to establish the time index which is being drawn.
|
||||
*/
|
||||
void update(void);
|
||||
void update();
|
||||
|
||||
/// Get the total time elapsed since the timer start, not counting paused time
|
||||
/**
|
||||
@ -92,13 +92,13 @@ public:
|
||||
* does not count the time elapsed while the timer is paused().
|
||||
* \return Total time elapsed since the timer start() to the last update() excluding time paused() in milliseconds
|
||||
*/
|
||||
unsigned long getMilliseconds(void);
|
||||
unsigned long getMilliseconds() const;
|
||||
|
||||
/// Alias of getMilliseconds() which returns time in seconds
|
||||
/**
|
||||
* \return Total time elapsed since the timer start() to the last update() excluding time paused() in seconds
|
||||
*/
|
||||
double getSeconds(void);
|
||||
double getSeconds() const;
|
||||
|
||||
/// Get the total time elapsed since the timer start
|
||||
/**
|
||||
@ -106,12 +106,12 @@ public:
|
||||
* this includes any time accumulated during updates while paused()
|
||||
* \return Total time elapsed since the timer start() to the last update() including time paused() in milliseconds
|
||||
*/
|
||||
unsigned long totalMilliseconds(void);
|
||||
unsigned long totalMilliseconds() const;
|
||||
/// Alias of totalMilliseconds() which returns time in seconds
|
||||
/**
|
||||
* \return Total time elapsed since the timer start() to the last update() including time paused() in seconds
|
||||
*/
|
||||
double totalSeconds(void);
|
||||
double totalSeconds() const;
|
||||
|
||||
/// Set the amount of time elapsed
|
||||
/**
|
||||
@ -132,7 +132,7 @@ public:
|
||||
* an average frame rate. Also useful for merely determining how many frames have been drawn.
|
||||
* \return Number of times update() has been called
|
||||
*/
|
||||
unsigned long getNumUpdates(void);
|
||||
unsigned long getNumUpdates() const;
|
||||
|
||||
/// Get the timer duration during the last update
|
||||
/**
|
||||
@ -140,12 +140,12 @@ public:
|
||||
* can be used to accurately control values with a per-second rate or determine the current frame rate.
|
||||
* \return Duration of time between the last two calls to update() in milliseconds
|
||||
*/
|
||||
unsigned long lastUpdateMilliseconds(void);
|
||||
unsigned long lastUpdateMilliseconds() const;
|
||||
/// Alias of lastUpdateMilliseconds() which returns time in seconds
|
||||
/**
|
||||
* \return Duration of time between the last two calls to update() in seconds
|
||||
*/
|
||||
double lastUpdateSeconds(void);
|
||||
double lastUpdateSeconds() const;
|
||||
|
||||
/// Set the timer pause state
|
||||
/**
|
||||
@ -160,7 +160,7 @@ public:
|
||||
/**
|
||||
* \return Current pause state, true if paused, false otherwise
|
||||
*/
|
||||
bool paused();
|
||||
bool paused() const;
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user