summaryrefslogtreecommitdiff
path: root/apps/Orbix-Examples/Logger/loggerS.cpp
blob: 51d9a70fd038e84c1d58f9ce2f3b6404edb7d1e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141

// $Id$

#include "logger.hh"


#define logger_dispatch_impl

unsigned char logger_dispatch::dispatch (CORBA::Request &IT_r, 
 unsigned char IT_isTarget, void *IT_pp) {
    if (!IT_pp)
       IT_pp = m_obj;
    const char *IT_s = IT_r.getOperation ();
    if (!strcmp(IT_s,"log")) {
        CORBA::Environment IT_env (IT_r);
        CORBA::Filter* IT_f = CORBA::Orbix.getFilter ();
        if (!IT_r.tcAssert ("\
Ro~log~+log_rec{R~logger::Log_Record~type{E~logger::Log_Priority~LM_MESSAGE,LM_DEBUG,LM_WARNING,LM_ERROR,LM_EMERG},time{l},app_id{l},host_addr{l},msg_data{S{c},0}},>{v},O{}\
"))
            return 1;
        logger::Log_Record log_rec;
        log_rec.decodeOp (IT_r);

        if (IT_f && !IT_r.isException (IT_env))
        	IT_f->inRequestPostM (IT_r, IT_env);
        if (!IT_r.isException (IT_env))
        ((logger*)IT_pp)->log ( log_rec, IT_env);

        IT_r.replyNoResults (CORBA::Flags(CORBA::INV_NO_RESPONSE),IT_env);
        return 1;
    }

    else if (!strcmp (IT_s,"_get_verbose")) {
        char verbose;
        CORBA::Environment IT_env (IT_r);
        CORBA::Filter* IT_f = CORBA::Orbix.getFilter ();
        if (!IT_r.tcAssert ("\
Ro~_get_verbose~>{c},N{}\
"))
            return 1;
        if (IT_f)
        	IT_f->inRequestPostM (IT_r, IT_env);
        if (!IT_r.isException (IT_env))
            verbose = ((logger*)IT_pp)->verbose(IT_env);

        if (!IT_r.isException (IT_env)) {
            if (!IT_r.convertToReply ("\
c\
", IT_env)) return 1;
            IT_r << verbose;
        }
        else IT_r.makeSystemException (IT_env);

        return 1;
  }
    else if (!strcmp (IT_s,"_set_verbose")) {
        CORBA::Environment IT_env (IT_r);
        CORBA::Filter* IT_f = CORBA::Orbix.getFilter ();
        if (IT_r.tcAssert ("\
Ro~_set_verbose~+{c},>{v},N{}\
")) {
            char verbose;
            IT_r >> verbose;
            if (IT_f && !IT_r.isException (IT_env))
            	IT_f->inRequestPostM (IT_r, IT_env);
            if (!IT_r.isException (IT_env))
            	((logger*)IT_pp)->verbose(verbose, IT_env);
        }
        IT_r.replyNoResults (IT_env);
        return 1;
    }

    else if (IT_isTarget)
        IT_r.makeRuntimeException2 ();

    return 0;
}

#define profile_logger_dispatch_impl

unsigned char profile_logger_dispatch::dispatch (CORBA::Request &IT_r, 
 unsigned char IT_isTarget, void *IT_pp) {
    if (!IT_pp)
       IT_pp = m_obj;
    const char *IT_s = IT_r.getOperation ();
    if (!strcmp(IT_s,"start_timer")) {
        CORBA::Environment IT_env (IT_r);
        CORBA::Filter* IT_f = CORBA::Orbix.getFilter ();
        if (!IT_r.tcAssert ("\
Ro~start_timer~>{v},N{}\
"))
            return 1;

        if (IT_f && !IT_r.isException (IT_env))
        	IT_f->inRequestPostM (IT_r, IT_env);
        if (!IT_r.isException (IT_env))
        ((profile_logger*)IT_pp)->start_timer (IT_env);

        IT_r.replyNoResults (IT_env);
        return 1;
    }

    else if (!strcmp(IT_s,"stop_timer")) {
        CORBA::Environment IT_env (IT_r);
        CORBA::Filter* IT_f = CORBA::Orbix.getFilter ();
        if (!IT_r.tcAssert ("\
Ro~stop_timer~-et{R~profile_logger::Elapsed_Time~real_time{d},user_time{d},system_time{d}},>{v},N{}\
"))
            return 1;
        profile_logger::Elapsed_Time et;

        if (IT_f && !IT_r.isException (IT_env))
        	IT_f->inRequestPostM (IT_r, IT_env);
        if (!IT_r.isException (IT_env))
        ((profile_logger*)IT_pp)->stop_timer ( et, IT_env);


        if (!IT_r.isException (IT_env)) {
            if (!IT_r.convertToReply ("\
v\
", IT_env)) return 1;
            et.encodeOp (IT_r);
            }

        else IT_r.makeSystemException (IT_env);
        return 1;
    }

    else if (logger_dispatch::dispatch (IT_r, 0,
         (logger*)((profile_logger*)IT_pp))) {
   return 1;
    }

    else if (IT_isTarget)
        IT_r.makeRuntimeException2 ();

    return 0;
}

#include "loggerC.cpp"