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

#include	"orb.h"
#include	<initguid.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_GUARD_RETURN (ACE_Thread_Mutex, guard, principal_lock_, 0);

  return ++_refcount;
}

ULONG __stdcall
CORBA_Principal::Release (void)
{
  ACE_GUARD_RETURN (ACE_Thread_Mutex, guard, principal_lock_, 0);

  if (--_refcount != 0)
    return _refcount;

  guard.release ();

  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;
}