00001
00002
00003
00004
00005
00006
00007
00009
00010 #ifndef _ALEPHREGISTEREDACTION_H_
00011 #define _ALEPHREGISTEREDACTION_H_
00012
00013 #include <vector>
00014
00015 #if defined(__GNUC__)
00016 #pragma interface
00017 #endif
00018
00019 class AlephAbstractInteractiveFunction;
00020 class AlephExManager;
00021
00022 template<class Type>
00023 class AlephRegisteredAction
00024 {
00025 public:
00026 AlephRegisteredAction();
00027 virtual ~AlephRegisteredAction() {}
00028 };
00029
00030
00031 #if defined(__GNUC__)
00032 #pragma implementation
00033 #endif
00034
00035 #include <typeinfo>
00036 #include "AlephAbstractInteractiveFunction.h"
00037 #include "AlephInteractiveHandler.h"
00038
00039 template <class Type>
00040 AlephRegisteredAction<Type>::AlephRegisteredAction()
00041 {
00042
00043 Type* myclass = new Type(AlephInteractiveHandler::TheAlephInteractiveHandler());
00044
00045 AlephAbstractInteractiveFunction* mycheckedclass = dynamic_cast<AlephAbstractInteractiveFunction*>(myclass);
00046 if(mycheckedclass==NULL)
00047 {
00048 cerr << "ERROR: tried to register the class " << typeid(myclass).name() << " as an AlephAbstractInteractiveFunction" << endl;
00049 delete myclass;
00050 return;
00051 }
00052
00053 string name = mycheckedclass->Name();
00054 for(vector<AlephAbstractInteractiveFunction*>::iterator existing = AlephInteractiveHandler::InteractiveFunctionsList.begin();
00055 existing<AlephInteractiveHandler::InteractiveFunctionsList.end(); existing++)
00056 if ((*existing)->Name() == name)
00057 {
00058 delete myclass;
00059 return;
00060 }
00061
00062 int code = mycheckedclass->Code();
00063 for(vector<AlephAbstractInteractiveFunction*>::iterator existing = AlephInteractiveHandler::InteractiveFunctionsList.begin();
00064 existing<AlephInteractiveHandler::InteractiveFunctionsList.end(); existing++)
00065 if ((*existing)->Code() == code)
00066 {
00067 delete *existing;
00068 *existing = myclass;
00069 return;
00070 }
00071
00072 AlephInteractiveHandler::InteractiveFunctionsList.push_back(myclass);
00073 }
00074
00075 #endif