]> SALOME platform Git repositories - modules/yacs.git/blob - src/runtime/CppComponent.hxx
Salome HOME
mergefrom branch BR_V511_PR tag mergeto_trunk_03feb09
[modules/yacs.git] / src / runtime / CppComponent.hxx
1 //  Copyright (C) 2006-2008  CEA/DEN, EDF R&D
2 //
3 //  This library is free software; you can redistribute it and/or
4 //  modify it under the terms of the GNU Lesser General Public
5 //  License as published by the Free Software Foundation; either
6 //  version 2.1 of the License.
7 //
8 //  This library is distributed in the hope that it will be useful,
9 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 //  Lesser General Public License for more details.
12 //
13 //  You should have received a copy of the GNU Lesser General Public
14 //  License along with this library; if not, write to the Free Software
15 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 #ifndef __YACS_CppCOMPONENT__
20 #define __YACS_CppCOMPONENT__
21
22 #include <string>
23 #include "ComponentInstance.hxx"
24
25 namespace YACS 
26 {
27   namespace ENGINE
28   {
29
30     class Any;
31
32     struct returnInfo {
33          int code;
34          std::string message;
35     };
36
37     typedef void * (*InitFunction)();
38     typedef void (*RunFunction) (void *, const char *, int, int, Any **, Any **, returnInfo *);
39     typedef void (*TerminateFunction)(void **);
40     typedef void (*PingFunction) ();
41         
42     class CppComponent : public ComponentInstance {
43       public:
44
45         CppComponent(const std::string & name);
46         CppComponent(void * obj, RunFunction r, TerminateFunction t, 
47                                const std::string & name) 
48              : __obj(obj), __run(r), __terminate(t), ComponentInstance(name) {}
49         CppComponent(const CppComponent& other);
50         virtual ~CppComponent();
51
52         void run(const char * service, int nbIn, int nbOut,
53                          Any ** argIn, Any ** argOut) throw (YACS::Exception);
54
55         static const char KIND[];
56         virtual std::string getKind() const;
57         virtual void load();
58         virtual void unload();
59         virtual bool isLoaded();
60         virtual ServiceNode* createNode(const std::string& name);
61         virtual YACS::ENGINE::ComponentInstance* clone() const;
62         
63       protected:
64   
65         void * __obj;
66         YACS::ENGINE::RunFunction __run;
67         YACS::ENGINE::TerminateFunction __terminate;
68     };
69   };
70 };
71
72 #endif