Giter VIP home page Giter VIP logo

enttx's People

Contributors

bantdit avatar

Stargazers

 avatar

Watchers

 avatar  avatar

enttx's Issues

Consider to refactor 'Entity::index()' and 'Entity::version()' methods w/out 'magic numbers'.

Consider to refactor 'Entity::index()' and 'Entity::version()' methods to

class Entity {
public:

    // ...

    auto index() const -> uint32_t { return static_cast<uint32_t>(id_ & INDEX_MASK); }
    auto version() const -> uint32_t { return static_cast<uint32_t>(id_ >> VERSION_SHIFT_VALUE); }

private:
    static auto constexpr INDEX_MASK{ 0xffffffffUL };
    static auto constexpr VERSION_SHIFT_VALUE{ 32UL };

    // ...
};

Consider to generalize 'EntityManager::createMany' for universal references

I. e., replace methods below

    template<size_t COUNT>
    auto createMany(std::array<Entity, COUNT>& entities, size_t count = 0) -> std::array<Entity, COUNT>&;

    template<size_t COUNT>
    auto createMany(std::array<Entity, COUNT>&& entities, size_t count = 0) -> std::array<Entity, COUNT>&&;

    auto createMany(std::vector<Entity>& entities, size_t count = 0) -> std::vector<Entity>&;

    auto createMany(std::vector<Entity>&& entities, size_t count = 0) -> std::vector<Entity>&&;

to one

    template<class T, typename std::enable_if_t<is_container_v<std::decay_t<T>>>...>
    auto createMany(T &&entities, size_t count = 0)
    {
        static_assert(std::is_same_v<typename std::decay_t<T>::value_type, Entity>, "'entities' must contain 'Entity' instances");

        return _createMany(std::forward<T>(entities), count > 0 ? count : std::size(entities));
    }

A little MPL helper function might be like follow one

template<class C>
constexpr bool is_iterable_v = is_iterable<C>::value;

template<class C, class = void>
struct is_container : std::false_type {};

template<class C>
struct is_container<C, std::void_t<decltype(std::size(std::declval<C>()), std::data(std::declval<C>()))>> : std::true_type {};

template<class C>
constexpr bool is_container_v = is_container<C>::value;

'Entity' class default constructor logic

There is no need to define custom default constructor like this

Entity()
      : id_{ std::numeric_limits<uint64_t>::max() }
    {}

Way better for interface if you replace it to

class Entity {
public:
    Entity() noexcept = default;

private:
    uint64_t id_{ std::numeric_limits<uint64_t>::max() };
};

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.