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