I'm getting the following linker errors:
Error 1 error LNK2001: unresolved external symbol "public: __thiscall AguiEvent<class AguiEmptyEventArgs>::AguiEvent<class AguiEmptyEventArgs>(void)" (??0?$AguiEvent@VAguiEmptyEventArgs@@@@QAE@XZ) AguiWidgetBase.obj
Error 2 error LNK2001: unresolved external symbol "public: void __thiscall AguiEvent<class AguiEmptyEventArgs>::call(class AguiEmptyEventArgs)" (?call@?$AguiEvent@VAguiEmptyEventArgs@@@@QAEXVAguiEmptyEventArgs@@@Z) AguiWidgetBase.obj
Error 3 error LNK2001: unresolved external symbol "public: __thiscall AguiEvent<class AguiControlEventArgs>::AguiEvent<class AguiControlEventArgs>(void)" (??0?$AguiEvent@VAguiControlEventArgs@@@@QAE@XZ) AguiWidgetBase.obj
Error 4 error LNK2001: unresolved external symbol "public: void __thiscall AguiEvent<class AguiControlEventArgs>::call(class AguiControlEventArgs)" (?call@?$AguiEvent@VAguiControlEventArgs@@@@QAEXVAguiControlEventArgs@@@Z) AguiWidgetBase.obj
Error 5 fatal error LNK1120: 4 unresolved externals C:\Users\Josh\Documents\Visual Studio 2008\Projects\Agui\STATIC Release\Agui.exe
I have AguiEventArgs.h which has this:
class AguiWidgetBase;
class AguiEmptyEventArgs {
public:
AguiEmptyEventArgs();
};
class AguiMouseEventArgs {
AguiPoint position;
int mouseWheelChange;
AguiMouseButtonEnum button;
public:
AguiPoint getPosition() const;
int getMouseWheelChange() const;
AguiMouseButtonEnum getButton() const;
int getX() const;
int getY() const;
AguiMouseEventArgs();
AguiMouseEventArgs(const AguiPoint &position,
int mouseWheelChange, AguiMouseButtonEnum button);
};
class AguiKeyEventArgs {
AguiKeyEnum key;
AguiKeyModifierEnum modKey;
bool isAlt;
bool isControl;
bool isShift;
public:
bool getAlt() const;
bool getControl() const;
bool getShift() const;
AguiKeyEnum getKey() const;
AguiKeyModifierEnum getModifierKeyFlags() const;
AguiKeyEventArgs();
AguiKeyEventArgs(AguiKeyEnum key, AguiKeyModifierEnum modKey);
};
class AguiControlEventArgs {
AguiWidgetBase* control;
public:
AguiWidgetBase* getControl() const;
AguiControlEventArgs();
AguiControlEventArgs(AguiWidgetBase* control);
};
I have double checked and defined all of these.
My Agui event is here:
template <typename T>
class AguiEvent {
void (*onEvent)(T arg);
public:
void setHandler(void (*eventProc)(T arg));
void removeHandler();
void call(T arg);
AguiEvent();
};
its defined:
template <typename T>
void AguiEvent<T>::setHandler( void (*eventProc)(T arg) )
{
onEvent = eventProc;
}
template <typename T>
void AguiEvent<T>::removeHandler()
{
onEvent = 0;
}
template <typename T>
void AguiEvent<T>::call(T arg)
{
if(onEvent)
onEvent(arg);
}
template <typename T>
AguiEvent<T>::AguiEvent()
{
onEvent = 0;
}
it is used like this:
AguiEvent<AguiEmptyEventArgs> eventThemeChanged;
AguiEvent<AguiControlEventArgs> eventChildControlAdded;
AguiEvent<AguiControlEventArgs> eventChildControlRemoved;
ex:
void AguiWidgetBase::addChildControl( AguiWidgetBase *control )
{
onAddChildControl(control);
eventChildControlAdded.call(AguiControlEventArgs(control));
}
Thanks