ALL: removed unused code

master
Martin Gerhardy 2022-01-28 20:06:41 +01:00
parent 7b035de1fe
commit 541540eda3
12 changed files with 27 additions and 178 deletions

View File

@ -9,7 +9,7 @@
#include "Shared_generated.h" #include "Shared_generated.h"
/** /**
* @defgroup Animation * @defgroup Animation Animation
* @{ * @{
* @brief Skeletal animation with lua configuration support. * @brief Skeletal animation with lua configuration support.
* *

View File

@ -20,6 +20,8 @@ namespace io {
/** /**
* @see SeekableReadStream * @see SeekableReadStream
* @see SeekableWriteStream * @see SeekableWriteStream
* @see MemoryReadStream
* @ingroup IO
*/ */
class BufferedReadWriteStream : public SeekableReadStream, public SeekableWriteStream { class BufferedReadWriteStream : public SeekableReadStream, public SeekableWriteStream {
private: private:

View File

@ -11,6 +11,7 @@ namespace io {
/** /**
* @brief Read from a zip input stream and save in a local buffer * @brief Read from a zip input stream and save in a local buffer
* *
* @ingroup IO
* @see ZipReadStream * @see ZipReadStream
* @see ZipWriteStream * @see ZipWriteStream
* @see MemoryReadStream * @see MemoryReadStream

View File

@ -22,6 +22,7 @@ typedef core::SharedPtr<File> FilePtr;
/** /**
* @brief File read and write capable stream * @brief File read and write capable stream
* *
* @ingroup IO
* @see SeekableReadStream * @see SeekableReadStream
* @see SeekableWriteStream * @see SeekableWriteStream
*/ */

View File

@ -9,7 +9,9 @@
namespace io { namespace io {
/** /**
* @ingroup IO
* @see SeekableReadStream * @see SeekableReadStream
* @see BufferedReadWriteStream
*/ */
class MemoryReadStream : public SeekableReadStream { class MemoryReadStream : public SeekableReadStream {
protected: protected:

View File

@ -11,8 +11,16 @@
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
/**
* @defgroup IO IO
* @{
*/
namespace io { namespace io {
/**
* @ingroup IO
*/
class ReadStream : public core::NonCopyable { class ReadStream : public core::NonCopyable {
public: public:
virtual ~ReadStream() {} virtual ~ReadStream() {}
@ -55,6 +63,7 @@ public:
/** /**
* @brief ReadStream with the option to jump back and forth in while reading * @brief ReadStream with the option to jump back and forth in while reading
* @ingroup IO
*/ */
class SeekableReadStream : public ReadStream { class SeekableReadStream : public ReadStream {
public: public:
@ -98,6 +107,9 @@ inline bool SeekableReadStream::empty() const {
return size() == 0; return size() == 0;
} }
/**
* @ingroup IO
*/
class WriteStream : public core::NonCopyable { class WriteStream : public core::NonCopyable {
public: public:
virtual ~WriteStream() {} virtual ~WriteStream() {}
@ -137,6 +149,7 @@ public:
/** /**
* @brief WriteStream with the option to jump back and forth in while writing * @brief WriteStream with the option to jump back and forth in while writing
* @ingroup IO
*/ */
class SeekableWriteStream : public WriteStream { class SeekableWriteStream : public WriteStream {
public: public:
@ -150,3 +163,8 @@ public:
}; };
} // namespace io } // namespace io
/**
* @}
*/

View File

@ -13,6 +13,7 @@ namespace io {
/** /**
* @see BufferedZipReadStream * @see BufferedZipReadStream
* @see ZipWriteStream * @see ZipWriteStream
* @ingroup IO
*/ */
class ZipReadStream : public io::ReadStream { class ZipReadStream : public io::ReadStream {
private: private:

View File

@ -14,6 +14,7 @@ namespace io {
* @see BufferedZipReadStream * @see BufferedZipReadStream
* @see ZipReadStream * @see ZipReadStream
* @see WriteStream * @see WriteStream
* @ingroup IO
*/ */
class ZipWriteStream : public io::WriteStream { class ZipWriteStream : public io::WriteStream {
private: private:

View File

@ -1,12 +1,10 @@
set(SRCS set(SRCS
IProgressMonitor.h
EMailValidator.h EMailValidator.cpp EMailValidator.h EMailValidator.cpp
BufferUtil.cpp BufferUtil.h BufferUtil.cpp BufferUtil.h
Console.h Console.cpp Console.h Console.cpp
KeybindingParser.h KeybindingParser.cpp KeybindingParser.h KeybindingParser.cpp
KeybindingHandler.h KeybindingHandler.cpp KeybindingHandler.h KeybindingHandler.cpp
IncludeUtil.h IncludeUtil.cpp IncludeUtil.h IncludeUtil.cpp
MessageQueue.h MessageQueue.cpp
VarUtil.h VarUtil.h
) )
set(LIB util) set(LIB util)

View File

@ -1,37 +0,0 @@
/**
* @file
*/
#pragma once
namespace util {
class IProgressMonitor {
protected:
long _max;
long _steps;
public:
IProgressMonitor(long max = 100l):
_max(max), _steps(0l) {
}
virtual ~IProgressMonitor() {
}
void init(long max) {
_max = max;
}
virtual void step(long steps = 1l) {
_steps += steps;
}
virtual void done() {
}
double progress() const {
return _steps * 100.0 / static_cast<double>(_max);
}
};
}

View File

@ -1,63 +0,0 @@
/**
* @file
*/
#include "MessageQueue.h"
#include "command/Command.h"
#include <algorithm>
namespace {
const double MessageDelay = 2.0;
}
void MessageQueue::message(const char *msg, ...) {
va_list ap;
const size_t bufSize = 4096;
char buf[bufSize];
va_start(ap, msg);
SDL_vsnprintf(buf, bufSize, msg, ap);
buf[sizeof(buf) - 1] = '\0';
va_end(ap);
_messageEventQueue.emplace_back(_timeSeconds + MessageDelay, buf);
std::push_heap(_messageEventQueue.begin(), _messageEventQueue.end(), _messageEventQueueComp);
}
void MessageQueue::construct() {
command::Command::registerCommand("addmessage", [&] (const command::CmdArgs& args) {
if (args.empty()) {
return;
}
message("%s", args.front().c_str());
});
}
bool MessageQueue::init() {
return true;
}
void MessageQueue::shutdown() {
_messageEventQueue.clear();
command::Command::unregisterCommand("addmessage");
}
void MessageQueue::update(double deltaFrameSeconds) {
_timeSeconds += deltaFrameSeconds;
if (_messageEventQueue.empty()) {
return;
}
// update queue and remove outdated messages
for (;;) {
const auto& msg = _messageEventQueue.front();
const double remainingMillis = msg.ttlSeconds - _timeSeconds;
if (remainingMillis > 0.0) {
break;
}
std::pop_heap(_messageEventQueue.begin(), _messageEventQueue.end(), _messageEventQueueComp);
_messageEventQueue.pop_back();
if (_messageEventQueue.empty()) {
break;
}
}
}

View File

@ -1,75 +0,0 @@
/**
* @file
*/
#pragma once
#include "core/IComponent.h"
#include "core/String.h"
#include "core/Common.h"
#include "core/StandardLib.h"
#include <stdint.h>
#include <vector>
/**
* @brief Class that implements messages with lifetime. The messages are removed once they got old enough.
*
* This can e.g. be used to display hud messages
*/
class MessageQueue : public core::IComponent {
private:
struct MessageEvent {
MessageEvent(double _ttlSeconds, const core::String& _msg) :
ttlSeconds(_ttlSeconds), msg(_msg) {
}
double ttlSeconds;
core::String msg;
};
struct MessageEventComparator {
inline bool operator()(const MessageEvent& x, const MessageEvent& y) const {
return x.ttlSeconds > y.ttlSeconds;
}
};
typedef std::vector<MessageEvent> MessageEventQueue;
MessageEventQueue _messageEventQueue;
MessageEventComparator _messageEventQueueComp;
double _timeSeconds = 0.0;
public:
/**
* @brief Registers a console command to add messages from scripts or console
*/
void construct() override;
/**
* @brief Initializes this component
* @sa @c shutdown()
*/
bool init() override;
/**
* @brief The update method will remove outdated messages.
*/
void update(double deltaFrameSeconds);
/**
* @brief Perform a cleanup of the component.
* @sa @c init()
*/
void shutdown() override;
/**
* @brief Adds a message to the message queue
*/
void message(CORE_FORMAT_STRING const char *msg, ...) CORE_PRINTF_VARARG_FUNC(2);
/**
* @brief Iterates over all active messages and call the given functor with the remaining millis and the string of the message
* @note The oldest messages are coming first
* @note Call @c update() to get rid of outdated messages
*/
template<class FUNC>
inline void visitMessages(FUNC&& func) const {
for (const auto& m : _messageEventQueue) {
func(m.ttlSeconds - _timeSeconds, m.msg);
}
}
};