Rework stdext classes

Implement new classes:
* stdext::any => ligher replacement for boost::any
* stdext::packed_any => like any but optimized to use less memory
* stdext::shared_object => ligher replacement for std::shared_ptr
* stdext::shared_object_ptr => replacement for boost::intrusive_ptr
* stdext::fast_storage => for storing dynamic data
* stdext::packed_storage => same but with less memory
* stdext::packed_vector => std::vector with less memory

Compiling should be a little faster now because global boost including
is not needed anymore
This commit is contained in:
Eduardo Bart
2012-08-01 04:49:09 -03:00
parent 1dc7dc0cfc
commit 3bac3dcbb4
92 changed files with 1885 additions and 1208 deletions

View File

@@ -33,11 +33,11 @@ class ScheduledEvent;
class FileStream;
class BinaryTree;
typedef boost::intrusive_ptr<Module> ModulePtr;
typedef boost::intrusive_ptr<Event> EventPtr;
typedef boost::intrusive_ptr<ScheduledEvent> ScheduledEventPtr;
typedef boost::intrusive_ptr<FileStream> FileStreamPtr;
typedef boost::intrusive_ptr<BinaryTree> BinaryTreePtr;
typedef stdext::shared_object_ptr<Module> ModulePtr;
typedef stdext::shared_object_ptr<Event> EventPtr;
typedef stdext::shared_object_ptr<ScheduledEvent> ScheduledEventPtr;
typedef stdext::shared_object_ptr<FileStream> FileStreamPtr;
typedef stdext::shared_object_ptr<BinaryTree> BinaryTreePtr;
typedef std::vector<BinaryTreePtr> BinaryTreeVec;

View File

@@ -26,6 +26,8 @@
#include "clock.h"
#include "scheduledevent.h"
#include <queue>
// @bindsingleton g_dispatcher
class EventDispatcher
{

View File

@@ -62,7 +62,7 @@ public:
void addString(const std::string& v);
BinaryTreePtr makeTree();
FileStreamPtr asFileStream() { return self_cast<FileStream>(); }
FileStreamPtr asFileStream() { return static_self_cast<FileStream>(); }
private:
void checkWrite();

View File

@@ -25,6 +25,8 @@
#include "../global.h"
#include <fstream>
struct LogMessage {
LogMessage(Fw::LogLevel level, const std::string& message, std::size_t when) : level(level), message(message), when(when) { }
Fw::LogLevel level;

View File

@@ -56,7 +56,7 @@ public:
int getAutoLoadPriority() { return m_autoLoadPriority; }
// @dontbind
ModulePtr asModule() { return self_cast<Module>(); }
ModulePtr asModule() { return static_self_cast<Module>(); }
protected:
void discover(const OTMLNodePtr& moduleNode);

View File

@@ -43,7 +43,7 @@ void ModuleManager::discoverModules()
for(const std::string& moduleDir : moduleDirs) {
auto moduleFiles = g_resources.listDirectoryFiles("/" + moduleDir);
for(const std::string& moduleFile : moduleFiles) {
if(boost::ends_with(moduleFile, ".otmod")) {
if(stdext::ends_with(moduleFile, ".otmod")) {
ModulePtr module = discoverModule("/" + moduleDir + "/" + moduleFile);
if(module && module->isAutoLoad())
m_autoLoadModules.insert(std::make_pair(module->getAutoLoadPriority(), module));

View File

@@ -125,7 +125,7 @@ void ResourceManager::searchAndAddPackages(const std::string& packagesDir, const
auto files = listDirectoryFiles(packagesDir);
for(auto it = files.rbegin(); it != files.rend(); ++it) {
const std::string& file = *it;
if(!boost::ends_with(file, packageExt))
if(!stdext::ends_with(file, packageExt))
continue;
std::string package = getRealDir(packagesDir) + "/" + file;
if(!addSearchPath(package, true))
@@ -262,7 +262,7 @@ std::list<std::string> ResourceManager::listDirectoryFiles(const std::string& di
std::string ResourceManager::resolvePath(const std::string& path)
{
std::string fullPath;
if(boost::starts_with(path, "/"))
if(stdext::starts_with(path, "/"))
fullPath = path;
else {
std::string scriptPath = "/" + g_lua.getCurrentSourcePath();
@@ -270,9 +270,9 @@ std::string ResourceManager::resolvePath(const std::string& path)
fullPath += scriptPath + "/";
fullPath += path;
}
if(!(boost::starts_with(fullPath, "/")))
if(!(stdext::starts_with(fullPath, "/")))
g_logger.traceWarning(stdext::format("the following file path is not fully resolved: %s", path));
boost::replace_all(fullPath, "//", "/");
stdext::replace_all(fullPath, "//", "/");
return fullPath;
}