Skip to content

Dheovani/ReflectionSystem

Repository files navigation

C++ Reflection System

Welcome to the C++ Reflection Library! This library provides a powerful and flexible way to add reflection capabilities to your C++ classes. With this library, you can easily introspect classes, their attributes, and methods at runtime. πŸš€

🌟 Features

  • Reflect on class attributes and methods.
  • Generate human-readable class information.
  • Easily extendable and customizable.
  • Minimal overhead and easy integration.

πŸ“š Installation

  1. Clone the repository:
git clone https://github.com/Dheovani/ReflectionSystem.git
  1. Include the header files in your project:
#include "reflection_system.h"

πŸš€ Usage

Here's a quick example to get you started:

#include <iostream>
#include "reflection_system.h"

using reflection_system::Reflective;

class Base {};

struct BaseStruct {};

class Derived : public Reflective<Derived>, public Base, public BaseStruct
{
    std::string str = "string";
    static const long long fl = 5;

    void func1() { std::cout << "func1" << std::endl; }
    int func2() { return 0; }

public:
    Derived() = default;

    Derived(const std::string& s, const long long& f) : str(s)
    {}

    static void StaticMethod(void) { std::cout << "In the static method" << std::endl; }

    void SetStr(const std::string& s) { this->str = s; }

    void PrintMethods() const {
        FillMethodList();
        for (auto& method : GetMethods())
            std::cout << method.sign << std::endl;
    }

    PARENT_CLASSES(Reflective<Derived>, Base, BaseStruct)
    ATTRIBUTES(str, fl)
    METHODS(func1, func2, StaticMethod, PrintMethods)
};

int main(int argc, char** argv)
{
    Derived derived;
    std::cout << derived << std::endl;

    return 0;
}

πŸ“ TODO

Here are some tasks and improvements planned for the C++ Introspection System:

  • πŸ› οΈ Add Support for Parent Classes: Implement introspection for parents, allowing dynamic data gathering.
  • πŸ“š Documentation: Expand the documentation with detailed usage examples and best practices.
  • πŸ§ͺ Testing: Increase unit test coverage to ensure the robustness and reliability of the system.
  • 🌐 Multi-format Serialization Support: Implement support for additional serialization formats, such as JSON.
  • πŸ”’ Access Modifiers: Find a way to verify if methods are either private, protected or public.

Feel free to contribute to any of these tasks or suggest new features and improvements!

πŸŽ“ Contributing

Contributions are welcome! Please feel free to submit a pull request or open an issue.

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

Special thanks to the following projects for their inspiration and contributions to the C++ community:

Happy Coding! 😊