OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / I386LINUX / util / I386LINUX / doc / mico / examples / redlich / Hello-4 / 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"
9 #include "ttyplus.h"
10
11
12 using namespace std;
13
14 class tty_impl : virtual public Hello3::tty_skel,
15                  virtual public Hello4::ttyplus_skel  {
16    ofstream   f;
17    long       ln;
18    int        max_col;
19
20 public:
21    tty_impl(char* fname) :f(fname) { ln= 1; max_col= 80; }
22    ~tty_impl()                     { f.close();}
23
24
25    void  columns(CORBA::Short n)  {
26             max_col= n; }
27
28    CORBA::Short  columns(void)  {
29             return max_col; }
30
31    CORBA::Long  lines(void)  {
32             return ln; }
33
34    void  clrscr(void) {
35             for (int i= 10; --i>=0; f << endl);
36             f.flush(); }
37
38    void  print(const char* msg)   {
39             for (int col=0; msg[col]; f << msg[col++])  {
40                  if (((col+1) % max_col) == 0)  {
41                         f << endl; ++ln;
42                  }
43             }
44             f << endl; f.flush(); ++ln; }
45 };
46
47
48
49 int main(int argc, char* argv[])   {
50   CORBA::ORB_var  orb;
51   CORBA::BOA_var  boa;
52   tty_impl        *obj_impl;
53
54         // Initialisierung
55   orb= CORBA::ORB_init(argc, argv, "mico-local-orb");
56   boa= orb->BOA_init(argc, argv, "mico-local-boa");
57
58         // Objekt-Implementation erzeugen
59   obj_impl= new tty_impl("/dev/tty");
60
61         // Objekt-Referenz (als String) ausgeben
62   cout << "Objekt-Referenz dieser tty-Implementation:" << endl;
63   cout << "\t" << orb->object_to_string(obj_impl) << endl;
64   cout.flush();
65  
66         // Warten auf Klienten
67   boa->impl_is_ready (CORBA::ImplementationDef::_nil());
68   orb->run ();
69
70   return 0;
71 }