More CMake bullshit

This commit is contained in:
sippeangelo
2015-11-30 11:16:43 +01:00
parent 8419d2e7b9
commit 52278d7bc2
20 changed files with 264 additions and 85 deletions
+2 -2
View File
@@ -16,7 +16,7 @@
class InputManager
{
public:
InputManager(GLFWwindow* window, std::shared_ptr<dd::EventBroker> eventBroker)
InputManager(GLFWwindow* window, std::shared_ptr<::EventBroker> eventBroker)
: m_GLFWWindow(window)
, EventBroker(eventBroker)
, m_CurrentKeyState()
@@ -37,7 +37,7 @@ public:
private:
GLFWwindow* m_GLFWWindow;
std::shared_ptr<dd::EventBroker> EventBroker;
std::shared_ptr<::EventBroker> EventBroker;
EventRelay<InputManager, Events::LockMouse> m_ELockMouse;
bool OnLockMouse(const Events::LockMouse &event);
-1
View File
@@ -9,7 +9,6 @@
#include <fstream>
#include "Util/UnorderedMapPair.h"
#include "Util/Factory.h"
#include "Util/FileWatcher.h"
/** Base Resource class.
+13
View File
@@ -0,0 +1,13 @@
#ifndef BoostPathHash_h__
#define BoostPathHash_h__
struct BoostPathHash
{
template <typename T>
std::size_t operator()(const boost::filesystem::path& p) const
{
return boost::filesystem::hash_value(p);
}
};
#endif
+14
View File
@@ -0,0 +1,14 @@
#ifndef EnumClassHash_h__
#define EnumClassHash_h__
// http://stackoverflow.com/a/24847480/417018
struct EnumClassHash
{
template <typename T>
std::size_t operator()(T t) const
{
return static_cast<std::size_t>(t);
}
};
#endif
+67
View File
@@ -0,0 +1,67 @@
#include <boost/filesystem.hpp>
#include <boost/thread.hpp>
#include <functional>
#include <unordered_map>
#include "Logging.h"
#include "BoostPathHash.h"
class FileWatcher
{
public:
enum class FileEventFlags;
typedef std::function<void(std::string, FileEventFlags)> FileEventCallback_t;
FileWatcher();
FileWatcher(std::string rootPath);
~FileWatcher();
std::string RootPath() const { return m_RootPath.string(); }
void AddWatch(std::string path, FileEventCallback_t callback);
void Start();
bool IsRunning() const { return m_IsRunning; }
void Stop();
void Check();
private:
class Worker;
boost::filesystem::path m_RootPath;
boost::thread m_Thread;
Worker* m_Worker = nullptr;
bool m_IsRunning = false;
};
enum class FileWatcher::FileEventFlags
{
Nothing = 0,
Created = 1 << 0,
SizeChanged = 1 << 1,
TimestampChanged = 1 << 2,
Deleted = 1 << 3
};
inline FileWatcher::FileEventFlags operator|(FileWatcher::FileEventFlags a, FileWatcher::FileEventFlags b) { return static_cast<FileWatcher::FileEventFlags>(static_cast<int>(a) | static_cast<int>(b)); }
inline bool operator&(FileWatcher::FileEventFlags a, FileWatcher::FileEventFlags b) { return static_cast<int>(a)& static_cast<int>(b); }
class FileWatcher::Worker
{
public:
void operator()();
void AddWatch(std::string path, FileEventCallback_t callback);
void Check();
private:
struct FileInfo
{
int Size;
std::time_t Timestamp;
};
std::unordered_map<boost::filesystem::path, FileEventCallback_t, BoostPathHash> m_FileCallbacks;
std::unordered_map<boost::filesystem::path, FileInfo, BoostPathHash> m_FileInfo;
boost::mutex m_Mutex;
FileInfo GetFileInfo(boost::filesystem::path path);
FileEventFlags UpdateFileInfo(boost::filesystem::path path);
};
+3 -3
View File
@@ -1,5 +1,5 @@
#ifndef Util_Logging_h__
#define Util_Logging_h__
#ifndef Logging_h__
#define Logging_h__
#ifdef _WIN32
// http://stackoverflow.com/a/2282433
@@ -19,7 +19,7 @@
#include <cstdio>
#include <stdarg.h>
enum class LogLevel
enum _LOG_LEVEL
{
LOG_LEVEL_ERROR,
LOG_LEVEL_INFO,
@@ -0,0 +1,17 @@
#ifndef UnorderedMapPair_h__
#define UnorderedMapPair_h__
#include <boost/functional/hash.hpp>
template<typename S, typename T> struct std::hash<std::pair<S, T>>
{
inline std::size_t operator()(const std::pair<S, T> &v) const
{
std::size_t seed = 0;
boost::hash_combine(seed, v.first);
boost::hash_combine(seed, v.second);
return seed;
}
};
#endif
+19
View File
@@ -0,0 +1,19 @@
#ifndef Image_h
#define Image_h
struct Image
{
enum class ImageFormat
{
Unknown,
RGB,
RGBA
};
unsigned int Width = 0;
unsigned int Height = 0;
ImageFormat Format = ImageFormat::Unknown;
unsigned char* Data = nullptr;
};
#endif
+3 -3
View File
@@ -47,9 +47,9 @@ public:
struct MaterialGroup
{
float Shininess;
std::shared_ptr<dd::Texture> Texture;
std::shared_ptr<dd::Texture> NormalMap;
std::shared_ptr<dd::Texture> SpecularMap;
std::shared_ptr<::Texture> Texture;
std::shared_ptr<::Texture> NormalMap;
std::shared_ptr<::Texture> SpecularMap;
unsigned int StartIndex;
unsigned int EndIndex;
};