OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / I386LINUX / util / I386LINUX / doc / mico / examples / redlich / Hello-2 / server.cc
1 #define MICO_CONF_IMR
2 #include <CORBA-SMALL.h>
3 #ifdef HAVE_ANSI_CPLUSPLUS_HEADERS
4 #include <fstream>
5 #else
6 #include <fstream.h>
7 #endif
8 #include "tty.h"           /* wurde aus 'tty.idl' generiert */
9
10
11 using namespace std;
12
13 /*
14  *  Typ einer Objekt-Implementation. Seine Instanzen besitzen
15  *  das in "tty.idl" definierte Interface 'tty'.
16  */
17
18 class tty_impl : virtual public tty_skel   {
19    ofstream f;            // private Daten dieser Objekt-Impl.
20 public:
21    tty_impl(char* fname) :f(fname)  {}
22    ~tty_impl()                      { f.close();}
23
24         // Ab hier werden die in "tty.idl" versprochenen
25         // Operationen bereitgestellt:
26   void print(const char* msg) {
27         f << msg << "\n"; f.flush(); }
28 };
29
30
31
32 /*
33  * Dieser Server stellt genau eine Objekt-Impl. bereit:
34  */
35
36 int main(int argc, char* argv[])   {
37   CORBA::ORB_var  orb;
38   CORBA::BOA_var  boa;
39   tty_impl        *obj_impl;
40
41         // Initialisierung:
42   orb = CORBA::ORB_init(argc, argv, "mico-local-orb");
43   boa = orb->BOA_init (argc, argv, "mico-local-boa");
44
45         // Objekt-Implementation erzeugen ....
46   obj_impl= new tty_impl("/dev/tty");
47
48         // ... und Obj-Ref (als String) ausgeben:
49   cout << "Objekt-Referenz dieser 'tty'-Implementation:\n";
50   cout << "\t" << orb->object_to_string(obj_impl) << "\n";
51   cout.flush();
52  
53         // Warten auf Klienten
54   boa->impl_is_ready (CORBA::ImplementationDef::_nil());
55   orb->run ();
56   return 0;
57 }