summaryrefslogtreecommitdiff
path: root/TAO/tao/principa.cpp
blob: 052d9d18743658e821935dc342ff7b6e2d1c9f4e (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
// @ (#)principa.cpp	1.4 95/11/04
// Copyright 1994-1995 by Sun Microsystems Inc.
// All Rights Reserved
//
// ORB:		Principal identifier pseudo-objref

#include "tao/corba.h"

void
CORBA::release (CORBA::Principal_ptr principal)
{
  if (principal)
    principal->Release ();
}

CORBA::Boolean
CORBA::is_nil (CORBA::Principal_ptr principal)
{
  return (CORBA::Boolean) (principal == 0);
}

CORBA_Principal::CORBA_Principal (void)
{
}

CORBA_Principal::~CORBA_Principal (void)
{
  assert (refcount_ == 0);

  if (id.buffer)
    delete [] id.buffer;
}

// For COM -- IUnKnown operations

// {A201E4C0-F258-11ce-9598-0000C07CA898}
DEFINE_GUID (IID_CORBA_Principal,
0xa201e4c0, 0xf258, 0x11ce, 0x95, 0x98, 0x0, 0x0, 0xc0, 0x7c, 0xa8, 0x98);


ULONG __stdcall
CORBA_Principal::AddRef (void)
{
  ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->lock_, 0));

  return ++refcount_;
}

ULONG __stdcall
CORBA_Principal::Release (void)
{
  {
    ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, mon, this->lock_, 0));

    if (--refcount_ != 0)
      return refcount_;
  }

  delete this;
  return 0;
}

HRESULT __stdcall
CORBA_Principal::QueryInterface (REFIID riid,
				 void **ppv)
{
  *ppv = 0;

  if (IID_CORBA_Principal == riid || IID_IUnknown == riid)
    *ppv = this;

  if (*ppv == 0)
    return ResultFromScode (E_NOINTERFACE);

  (void) AddRef ();
  return NOERROR;
}