Skip to content
Snippets Groups Projects
Commit 4794b2ea authored by BATON Theau's avatar BATON Theau
Browse files

Add Kernel + Physic Engine

parent d1f0d5c7
No related branches found
No related tags found
No related merge requests found
#include "Identifiable.hpp"
namespace megu {
size_t Identifiable::_GlobalId = 0;
Identifiable::Identifiable()
: _id(Identifiable::_GlobalId++) {}
Identifiable::Identifiable(size_t id)
: _id(id) {}
Identifiable::Identifiable(const Identifiable & src)
: _id(src._id) {}
Identifiable::~Identifiable() {
--Identifiable::_GlobalId;
}
bool Identifiable::operator==(const Identifiable & identifiable) const {
return this->_id == identifiable._id;
}
bool Identifiable::operator!=(const Identifiable & identifiable) const {
return !(*this == identifiable);
}
bool Identifiable::operator<=(const Identifiable & identifiable) const {
return this->_id <= identifiable._id;
}
bool Identifiable::operator>=(const Identifiable & identifiable) const {
return this->_id <= identifiable._id;
}
bool Identifiable::operator<(const Identifiable & identifiable) const {
return !(this->_id >= identifiable._id);
}
bool Identifiable::operator>(const Identifiable & identifiable) const {
return !(this->_id <= identifiable._id);
}
}
\ No newline at end of file
#pragma once
#include <map>
#include <stddef.h>
namespace megu {
class Identifiable {
public:
Identifiable();
Identifiable(size_t);
Identifiable(const Identifiable &);
virtual ~Identifiable();
inline size_t id() const {return this->_id;}
inline void setId(size_t id) {this->_id = id;}
bool operator==(const Identifiable &) const;
bool operator!=(const Identifiable &) const;
bool operator>=(const Identifiable &) const;
bool operator<=(const Identifiable &) const;
bool operator>(const Identifiable &) const;
bool operator<(const Identifiable &) const;
private:
size_t _id;
static size_t _GlobalId;
};
template <class T>
using Identifiable_Map = std::map<size_t, T *>;
template <class T>
class Identifiable_Unique : public Identifiable {};
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment