summaryrefslogtreecommitdiff
path: root/CIAO/ciao/Cookies.cpp
blob: 7679f31401b5866186596f6db948eba842e2455f (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
// $Id$
#include "Cookies.h"

#if !defined (__ACE_INLINE__)
#include "Cookies.inl"
#endif /* !defined INLINE */

ACE_RCSID (ciao,
           Cookies,
           "$Id$")

namespace CIAO
{
  Cookie_Impl::Cookie_Impl (CORBA::ULong const &key)
  {
    this->cookieValue ().length (sizeof (CORBA::ULong));
    ACE_OS::memcpy (this->cookieValue ().get_buffer (false),
                    &key,
                    sizeof (CORBA::ULong));
  }

  Cookie_Impl::~Cookie_Impl (void)
  {
  }

  bool
  Cookie_Impl::extract (Components::Cookie const * const ck,
                        CORBA::ULong &key)
  {
    Cookie_Impl const * const c =
      dynamic_cast <Cookie_Impl const * const> (ck);

    if (c == 0)
      {
        return false;
      }

    CORBA::OctetSeq const &x = c->cookieValue ();

    if (x.length () != sizeof (CORBA::ULong))
      {
        return false;
      }

    key = *reinterpret_cast<const CORBA::ULong *> (x.get_buffer ());

    return true;
  }

  //========================================================

  CORBA::ValueBase *
  Cookie_Impl_init::create_for_unmarshal (void)
  {
    CORBA::ValueBase *ret_val = 0;

    ACE_NEW_THROW_EX (ret_val,
                      CIAO::Cookie_Impl,
                      CORBA::NO_MEMORY ());

    return ret_val;
  }

  Cookie_Impl_init::~Cookie_Impl_init (void)
  {
  }
}