Muto 0.0.1
Cross-Platform Application Template
GitHub Repo | Muto Updates | Muto's Author
Loading...
Searching...
No Matches
Defines_Macros.h File Reference

Provides commonly used macros along with project wide typedefs. More...

Go to the source code of this file.

Namespaces

namespace  Muto
 The main namespace for the Muto engine.
 

Macros

#define BIND_EVENT_FN(x)   std::bind(&Application::x, this, std::placeholders::_1)
 Binds the given member function of the Application class as an event handler.
 
#define BIT(x)   (1 << x)
 Macro to shift 1 by x positions to create a bitmask.
 
#define EVENT_CLASS_CATEGORY(category)   virtual int GetCategoryFlags() const override { return category; }
 Macro to define event category in event subclasses.
 
#define EVENT_CLASS_TYPE(type)
 Macro to define event type in event subclasses.
 
#define MU_BIND_EVENT_FN(fn)   [this](auto&&... args) -> decltype(auto) { return this->fn(std::forward<decltype(args)>(args)...); }
 Binds a member function as an event handler.
 

Typedefs

template<typename T >
using Muto::Ref = std::shared_ptr< T >
 A smart pointer type representing shared ownership of an object.
 
template<typename T >
using Muto::Scope = std::unique_ptr< T >
 A smart pointer type representing exclusive ownership of an object.
 

Functions

template<typename T , typename... Args>
constexpr Ref< T > Muto::CreateRef (Args &&... args)
 Creates a Ref (shared_ptr) for the given type and constructor arguments.
 
template<typename T , typename... Args>
constexpr Scope< T > Muto::CreateScope (Args &&... args)
 Creates a Scope (unique_ptr) for the given type and constructor arguments.
 

Detailed Description

Provides commonly used macros along with project wide typedefs.

Author
Damon S. Green II

Macro Definition Documentation

◆ BIND_EVENT_FN

#define BIND_EVENT_FN (   x)    std::bind(&Application::x, this, std::placeholders::_1)

Binds the given member function of the Application class as an event handler.

Parameters
xThe member function to bind.

◆ BIT

#define BIT (   x)    (1 << x)

Macro to shift 1 by x positions to create a bitmask.

Parameters
xThe number of positions to shift.
Returns
The resulting bitmask.
Note
This macro is typically used for defining event categories.
Warning
Be cautious when using this macro with values greater than or equal to the number of bits in an integer, as it may lead to undefined behavior.
Attention
This macro is not type-safe; consider using constexpr functions or enum classes for better type safety.

◆ EVENT_CLASS_CATEGORY

#define EVENT_CLASS_CATEGORY (   category)    virtual int GetCategoryFlags() const override { return category; }

Macro to define event category in event subclasses.

Parameters
categoryThe event category to define.

◆ EVENT_CLASS_TYPE

#define EVENT_CLASS_TYPE (   type)
Value:
static EventType GetStaticType() { return EventType::ET_##type; }\
virtual EventType GetEventType() const override { return GetStaticType(); }\
virtual const char* GetName() const override { return #type; }

Macro to define event type in event subclasses.

Parameters
typeThe event type to define.
25 { return EventType::ET_##type; }\
26 virtual EventType GetEventType() const override { return GetStaticType(); }\
27 virtual const char* GetName() const override { return #type; }
EventType
Enumeration of event types.
Definition Event.h:12

◆ MU_BIND_EVENT_FN

#define MU_BIND_EVENT_FN (   fn)    [this](auto&&... args) -> decltype(auto) { return this->fn(std::forward<decltype(args)>(args)...); }

Binds a member function as an event handler.

Parameters
fnThe member function to bind.