AuroraInterfaces/README.md

50 lines
1.8 KiB
Markdown

## Aurora Interfaces
This library implements the macros required to define Aurora style interfaces. Defines two classes implementable by SWIG, CppSharp, and classical event interface inheritance; and implementable by std::function for modern C++ and runtime language bindings respectively. The former is simply defined as a structure containing virtual methods as laid out by AUI_METHODs. Latterly, the base interface is extended and implemented by an array of overloaded method defintions and std::function member fields. The latter type variant includes type defintions of each functional type, where each method type is defined as IMyInterfaceFunctional::methodName_t; and includes a copy and a move constructor for when the implementation is available at time of construction.
## Example usage:
#### In your public API:
```c
AUI_INTERFACE(IInputMouseSubscriber,
AUI_METHOD(void, onButtonPress, (AuUInt8, mb)),
AUI_METHOD(void, onButtonTick, (AuUInt8, mb)),
AUI_METHOD(void, onButtonUp, (AuUInt8, mb))
);
```
#### Usage: C++ inheritance (covers SWIG and CppSharp)
```
#include <AuroraForEach.hpp>
#include <AuroraInterfaces.hpp>
#include <[MyPublicAPI].hpp>
struct MyEventHandler : public IInputMouseSubscriber
{
void onButtonPress(AuUInt8 mb) override;
void onButtonTick(AuUInt8 mb) override;
void onButtonUp(AuUInt8 mb) override;
};
static AuSPtr<IInputMouseSubscriber> MyMouseSubscriber()
{
return AuMakeShared<MyEventHandler>();
}
```
#### Usage: Runtime bindings and modern C++
``` c++
// My language binding
auto test = AuMakeShared<IInputMouseSubscriberFunctional>();
test->onButtonPress = [](AuUInt8 btn)
{
};
```
## Dependencies
* [AuroraForEach](https://git.reece.sx/AuroraSupport/AuroraForEach) [header only]
##### Not recommended for small projects and/or people with a shred of sanity left
##### Possibly useful for API developers