summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/LWFT/ObjectReferenceFactory.cpp
blob: cacc0cdb40960b0b7dcc3bc088d899e928c14ae7 (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
// -*- C++ -*-
// $Id$

#include "ObjectReferenceFactory.h"
#include "tao/PortableServer/PortableServer.h"
#include "tao/Stub.h"
#include "tao/Profile.h"
#include "tao/debug.h"

ACE_RCSID (Hello,
           ObjectReferenceFactory,
           "$Id$")

ObjectReferenceFactory::ObjectReferenceFactory (
  PortableInterceptor::ObjectReferenceFactory * old_orf)
  : old_orf_ (old_orf)
{
  CORBA::add_ref (old_orf);
}

ObjectReferenceFactory::~ObjectReferenceFactory (void)
{
}

CORBA::Object_ptr
ObjectReferenceFactory::make_object (
    const char *repository_id,
    const PortableInterceptor::ObjectId & id)
{
  ACE_ASSERT (repository_id != 0);

  CORBA::String_var s = PortableServer::ObjectId_to_string (id);

  CORBA::Object_var ref = this->old_orf_->make_object (repository_id, id);

  TAO_MProfile &mp = ref->_stubobj ()->base_profiles ();

  IOP::TaggedComponent mytag;
  const char* tag = s.in ();
  CORBA::ULong tag_id = 9654;
  size_t tag_length = ACE_OS::strlen (tag); 
  mytag.tag = tag_id;
  mytag.component_data.length (tag_length + 1);

  CORBA::Octet *buf = mytag.component_data.get_buffer ();
  ACE_OS::memcpy (buf, tag, tag_length + 1);
  buf[tag_length] = '\0';

  const CORBA::ULong profile_count = mp.profile_count ();

  for (CORBA::ULong i = 0; i < profile_count; ++i)
    {
      TAO_Profile *profile = mp.get_profile (i);
      profile->add_tagged_component (mytag);
    }

  return ref._retn ();
}