summaryrefslogtreecommitdiff
path: root/TAO/tao/IORInfo.cpp
blob: ab7edb16ccbfcd1795ab8e685d549c4f431c6a77 (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
// -*- C++ -*-
//
// $Id$

#include "IORInfo.h"
#include "PolicyC.h"
#include "IOPC.h"
#include "MProfile.h"

ACE_RCSID (tao, IORInfo, "$Id$")


TAO_IORInfo::TAO_IORInfo (TAO_ORB_Core *orb_core,
			  TAO_MProfile &mp,
			  CORBA::PolicyList *policy_list)
  : orb_core_ (orb_core),
    mp_ (mp),
    policy_list_ (policy_list)
{
}

TAO_IORInfo::~TAO_IORInfo (void)
{
}

CORBA::Policy_ptr
TAO_IORInfo::get_effective_policy (CORBA::PolicyType type,
				   CORBA::Environment &ACE_TRY_ENV)
  ACE_THROW_SPEC ((CORBA::SystemException))
{
  // Check the policy list supplied by the POA.
  CORBA::ULong policy_count = this->policy_list_->length ();

  for (CORBA::ULong i = 0; i < policy_count; ++i)
    {
      CORBA::PolicyType pt =
	(*(this->policy_list_))[i]->policy_type (
          TAO_ENV_SINGLE_ARG_PARAMETER);
      ACE_CHECK_RETURN (CORBA::Policy::_nil ());

      if (pt == type)
	return CORBA::Policy::_duplicate ((*(this->policy_list_))[i]);
    }

  // TODO: Now check the global ORB policies.
  // ........

  ACE_THROW_RETURN (CORBA::INV_POLICY (TAO_OMG_VMCID | 2,
                                       CORBA::COMPLETED_NO),
		    CORBA::Policy::_nil ());
}

void
TAO_IORInfo::add_ior_component (const IOP::TaggedComponent &component,
				CORBA::Environment &ACE_TRY_ENV)
  ACE_THROW_SPEC ((CORBA::SystemException))
{
  // Add the given tagged component to all profiles.

  CORBA::ULong profile_count = this->mp_.profile_count ();
  for (CORBA::ULong i = 0; i < profile_count; ++i)
    {
      TAO_Profile *profile = this->mp_.get_profile (i);

      profile->add_tagged_component (component, ACE_TRY_ENV);
      ACE_CHECK;
    }
}

void
TAO_IORInfo::add_ior_component_to_profile (
    const IOP::TaggedComponent &component,
    IOP::ProfileId profile_id,
    CORBA::Environment &ACE_TRY_ENV)
  ACE_THROW_SPEC ((CORBA::SystemException))
{
  // Add the given tagged component to all profiles matching the given
  // ProfileId.

  int found_profile = 0;

  CORBA::ULong profile_count = this->mp_.profile_count ();
  for (CORBA::ULong i = 0; i < profile_count; ++i)
    {
      TAO_Profile *profile = this->mp_.get_profile (i);

      if (profile->tag () == profile_id)
	{
	  profile->add_tagged_component (component, ACE_TRY_ENV);
          ACE_CHECK;

          found_profile = 1;
	}
    }

  // According to the Portable Interceptor specification, we're
  // supposed to throw a CORBA::BAD_PARAM exception if no profile
  // matched the given ProfileId.
  if (found_profile == 0)
    ACE_THROW (CORBA::BAD_PARAM (TAO_OMG_VMCID | 29,
                                 CORBA::COMPLETED_NO));
}