Salome HOME
copy tag mergefrom_BR_V0_1_CC_Salome_04oct07
[modules/yacs.git] / src / runtime / CppComponent.hxx
1 #ifndef __YACS_CppCOMPONENT__
2 #define __YACS_CppCOMPONENT__
3
4 #include <string>
5 #include "Any.hxx"
6 #include "ComponentInstance.hxx"
7
8 namespace YACS 
9 {
10   namespace ENGINE
11   {
12
13     struct returnInfo {
14          int code;
15          std::string message;
16     };
17
18     typedef void * (*InitFunction)();
19     typedef void (*RunFunction) (void *, const char *, int, int, Any **, Any **, returnInfo *);
20     typedef void (*TerminateFunction)(void **);
21     typedef void (*PingFunction) ();
22         
23     class CppComponent : public ComponentInstance {
24       public:
25
26         CppComponent(const std::string & name);
27         CppComponent(void * obj, RunFunction r, TerminateFunction t, 
28                                const std::string & name) 
29              : __obj(obj), __run(r), __terminate(t), ComponentInstance(name) {}
30         CppComponent(const CppComponent& other);
31         virtual ~CppComponent();
32
33         void run(const char * service, int nbIn, int nbOut,
34                          Any ** argIn, Any ** argOut) throw (YACS::Exception);
35
36         static const char KIND[];
37         virtual std::string getKind() const;
38         virtual void load();
39         virtual void unload();
40         virtual bool isLoaded();
41         virtual ServiceNode* createNode(const std::string& name);
42         virtual YACS::ENGINE::ComponentInstance* clone() const;
43         
44       protected:
45   
46         void * __obj;
47         YACS::ENGINE::RunFunction __run;
48         YACS::ENGINE::TerminateFunction __terminate;
49     };
50   };
51 };
52
53 #endif