-
Notifications
You must be signed in to change notification settings - Fork 6
ComponentCore
If you wish to create your own Components you need to understand few design choices. Every component in RadCat inherits from a BaseComponent class. This class has 2 methods and a variable,
-
virtual void update(){}function updates automaticly every CPU cycle. -
virtual bool initialize(){}function runs automaticly inside constructors. -
EmptyDevice* parentholds the parent device and assigned automaticly by the system when the device is created.
When you create a component you need to include base component with #include "componentCore.hpp" and inherit from base component with COMPONENT class FTDIConnection : public BaseComponent . COMPONENT is a special macro that makes some forward declarations for you. Also every component needs to have a constructor with a device set as template<typename DeviceType> CompName(DeviceType& parentDevice) : parent(&parentDevice) . This constructor is called automatically from devices so you dont need to call it manually at the device level.
Inside your CPP file you need to include device core with #include "deviceCore.hpp" otherwise your component will not compile!
Here is a component template for creators:
HPP:
#pragma once
#include "componentCore.hpp"
COMPONENT class MyNewComponent : public BaseComponent {
public:
template<typename DeviceType> FTDIConnection(DeviceType& parentDevice) : parent(&parentDevice) {Initialize()}
virtual void update() override;
virtual bool Initialize() override;
//More functions and variables here
}
CPP:
#include "deviceCore.hpp"
void MyNewComponent::update(){//Something here}
bool MyNewComponent::Initialize(){//Something here}