summaryrefslogtreecommitdiff
path: root/CIAO/DAnCE/LocalityManager/Scheduler/Deployment_Events.h
blob: 14dba5b20289bb0073d648bcf512b0c52764785f (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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/**
 * @file Deployment_Events.h
 * @author William R. Otte <wotte@dre.vanderbilt.eud>
 *
 * $Id$
 *
 * This file contains all schedulable deployment events.
 */

#ifndef DEPLOYMENT_EVENTS_H
#define DEPLOYMENT_EVENTS_H

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

#include "ace/Method_Request.h"
#include "ace/Future.h"
#include "Deployment/Deployment_DeploymentPlanC.h"
#include "LocalityManager/Scheduler/Deployment_Scheduler_export.h"

namespace DAnCE
{
  struct Deployment_Scheduler_Export Event_Result
  {
    std::string id_;
    bool exception_;
    CORBA::Any_var contents_;
  };
    
  typedef ACE_Future< Event_Result > Event_Future;
  
  /**
   * @class Event_Handler
   * @brief Future observer that invokes a parameterized functor on the future
   */
  template <typename Functor>
  class Deployment_Scheduler_Export Event_Handler
    : ACE_Future_Observer< Event_Result >
  {
  public:
    Event_Handler (Functor &specific_handler);
    
    virtual ~Event_Handler (void);

    virtual void update (const Event_Result &future);
    
    /// Indicate to the observer that there is an additional future
    /// it is waiting on
    void add_outstanding (void);
    
    /// Return the number of still outstanding future events.
    size_t count_outstanding (void);
  private:
    ACE_Atomic_Op < TAO_SYNCH_MUTEX, unsigned long > outstanding_;
    
    Functor &specific_handler_;
  };

  class Deployment_Scheduler_Export Deployment_Event : 
    public virtual ACE_Method_Request
  {
  public:
    Deployment_Event (Event_Future holder,
                      const char *instance_type);
    
    Event_Future get_future (void);
    
  protected:
    Event_Future holder_;
    std::string instance_type_;
  };
      
  class Deployment_Scheduler_Export Install_Instance :
    public virtual Deployment_Event
  {
  public:
    Install_Instance (const ::Deployment::DeploymentPlan & plan,
                      ::CORBA::ULong instanceRef,
                      const char *instance_type,
                      Event_Future holder);
    
    virtual ~Install_Instance (void);

    virtual int call (void);

  private:
    ::Deployment::DeploymentPlan plan_;
    ::CORBA::ULong instanceRef_;
  };
 
  class Deployment_Scheduler_Export Connect_Instance :
    public virtual Deployment_Event
  {
  public:
    Connect_Instance (const ::Deployment::DeploymentPlan & plan,
                      ::CORBA::ULong connectionRef,
                      const ::CORBA::Any &provided_ref,
                      const char *instance_type,
                      Event_Future holder);
    
    virtual ~Connect_Instance (void);

    virtual int call (void);

  private:
    ::Deployment::DeploymentPlan plan_;
    ::CORBA::ULong connectionRef_;
    ::CORBA::Any provided_ref_;
  };

  class Deployment_Scheduler_Export Remove_Instance :
    public virtual Deployment_Event
  {
  public:
    Remove_Instance (::Deployment::DeploymentPlan & plan,
                     ::CORBA::ULong instanceRef,
                     const CORBA::Any &reference,
                     const char *instance_type,
                     Event_Future holder);
    
    virtual ~Remove_Instance (void);

    virtual int call (void);

  private:
    ::Deployment::DeploymentPlan & plan_;
    ::CORBA::ULong instanceRef_;
    ::CORBA::Any reference_;
  };
}

#if defined (__ACE_INLINE__)
#include "LocalityManager/Scheduler/Deployment_Events.h"
#endif

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

#endif