summaryrefslogtreecommitdiff
path: root/modules/CIAO/ciao/Containers/Servant_Activator.h
blob: 212000136204a3d9b884f3904944457421946338 (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
// -*- C++ -*-

//=============================================================================
/**
 *  @file    Servant_Activator.h
 *
 *  $Id$
 *
 *  @authors Balachandran Natarajan <bala@dre.vanderbilt.edu>
 */
//=============================================================================

#ifndef CIAO_SERVANT_ACTIVATOR_H
#define CIAO_SERVANT_ACTIVATOR_H

#include /**/ "ace/pre.h"

#include "CIAO_Servant_Activator_export.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

#include "ace/Array_Base.h"
#include "tao/PortableServer/ServantActivatorC.h"
#include "tao/LocalObject.h"
#include "ciao/Containers/CIAO_Servant_ActivatorC.h"

#include <map>
#include <string>

namespace CIAO
{
  class Port_Activator;

  /**
   * @class Servant_Activator
   *
   * @brief Activator that is registered with the POA for facet and
   * consumer servants.
   *
   * This class acts like a factory in some sense. This factory is
   * registered with the POA with RETAIN policy. When the factory gets
   * a call back as part of the upcall, this factory looks at the
   * list of port activators registered, uses the OID to pick the
   * right one (yes a linear algorithm is used), calls activate () on
   * it which returns the servant for *that* port.
   */
  class CIAO_Servant_Activator_Export Servant_Activator_i
    : public virtual ::CIAO::Servant_Activator,
      public virtual ::CORBA::LocalObject
  {
  public:
    Servant_Activator_i (CORBA::ORB_ptr o);

    virtual ~Servant_Activator_i (void);

    virtual ::CORBA::Boolean update_port_activator (
      const ::PortableServer::ObjectId &oid);

    virtual ::CORBA::Boolean register_port_activator (
      ::CIAO::Port_Activator_ptr pa);

    /// Template methods overridden to get callbacks.
    /**
     * If you would like to know the details of the following two
     * methods, please PortableServer documentation. This is probably
     * not the place to document what these mean.
     */
    virtual PortableServer::Servant incarnate (
      const PortableServer::ObjectId &oid,
      PortableServer::POA_ptr poa);

    virtual void etherealize (const PortableServer::ObjectId &oid,
                              PortableServer::POA_ptr adapter,
                              PortableServer::Servant servant,
                              CORBA::Boolean cleanup_in_progress,
                              CORBA::Boolean remaining_activations);
    /// Local helper methods

  private:
    /// Pointer to our ORB
    CORBA::ORB_var orb_;

    typedef std::map <std::string, Port_Activator_var> Port_Activators;
    
    /// Array of port activators
    Port_Activators pa_;

    /// Running index of the slot that has been just filled in.
    size_t slot_index_;

    /// Mutex that synchronizes access to the array.
    TAO_SYNCH_MUTEX  mutex_;
  };
}

#include /**/ "ace/post.h"

#endif /*CIAO_SERVANT_ACTIVATOR_H*/