summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/DevGuideExamples/ValueTypes/Notify/Event_i.h
blob: a767bd47a5b1c0ef44c7110ba1a2d93915ff132a (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
// $Id$

#ifndef EVENT_H_
#define EVENT_H_

#include "EventS.h"

#include <iostream>
#include "tao/Valuetype/ValueFactory.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
#pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

class MyEvent_i
  : public virtual OBV_MyEvent
  , public virtual CORBA::DefaultValueRefCountBase
{
public:
  MyEvent_i(const char* n, CORBA::Long k)
  {
    name(n);
    kind(k);
  }

  virtual void dump ()
  {
    CORBA::LongSeq& pl = payload();
    ACE_DEBUG((LM_DEBUG, "\nPayload contents.\n"));
    for (CORBA::ULong i = 0; i < pl.length(); ++i)
    {
      ACE_DEBUG((LM_DEBUG, "%d = %d\n", i, pl[i]));
    }
    ACE_DEBUG((LM_DEBUG, "\n"));
  }

  virtual CORBA::Long size ()
  {
    return payload().length();
  }

  virtual void add_long (CORBA::Long n)
  {
    CORBA::LongSeq& pl = payload();
    CORBA::ULong idx = pl.length();
    pl.length(idx + 1);
    pl[idx] = n;
  }
};

class MyEventFactory
  : public virtual CORBA::ValueFactoryBase
{
public:

  virtual CORBA::ValueBase * create_for_unmarshal ()
  {
    // It doesn't matter what values we construct it with
    // because they will be overwritten with the demarshaled values.
    return new MyEvent_i("", -1);
  }
};


#endif /* EVENT_H_  */