summaryrefslogtreecommitdiff
path: root/SA_POP/server/client.h
blob: 737770a18de75317a0a000c2c453b8d134cdf99b (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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
// -*- C++ -*-
// $Id$

//=============================================================================
/**
 * @file  client.h
 *
 * This file contains the UIOption base class (and derived classes) definition
 * for objects that encode command options available to the user in client
 * interface.
 *
 * @author  John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
 */
//=============================================================================

#ifndef SA_POP_UI_OPTION_H_
#define SA_POP_UI_OPTION_H_

#include <string>
#include "SA_POP_Types.h"
#include "Driver.h"

namespace SA_POP {


  /**
   * @class UIOption
   *
   * @brief Abstract base class for objects that encode client command options.
   */
  class UIOption {
  public:
    /// Constructor.
    /**
     * @param descrip  Description of option for display in UI.
     *
     * @param undo_descrip  Description of undo option for display in UI.
     *
     * @param driver  Pointer to SA-POP driver to use during option invocation.
     */
    UIOption (std::string descrip, std::string undo_descrip,
      ::CIAO::RACE::SA_POP::Driver_ptr driver);

    /// Destructor.
    virtual ~UIOption (void);



    /// Get description of option for display in UI.
    /**
     * @return  Description of option.
     */
    virtual std::string get_descrip (void);

    /// Get whether option is active.
    /**
     * @return  True if option is active; false otherwise.
     */
    virtual bool is_active (void);

    /// Get whether option is invoked.
    /**
     * @return  True if option is invoked; false otherwise.
     */
    virtual bool is_invoked (void);

    /// Do option action (if not invoked, invoke; otherwise, undo).
    /**
     * @return  True if action succeeded; false if action failed.
     */
    virtual bool do_action (void);

  protected:
    /// Description of option (for display in UI).
    std::string descrip_;

    /// Description of undo option (for display in UI).
    std::string undo_descrip_;

    /// Flag indicating whether option is currently invoked.
    bool is_invoked_;

    /// Flag indicating whether option is active/available.
    bool is_active_;

    /// Pointer to SA-POP driver to use during invocation of option.
    ::CIAO::RACE::SA_POP::Driver_var driver_;

    /// Invoke option action.
    /**
     * @return  True if invocation succeeded; otherwise false.
     */
    virtual bool invoke (void) = 0;

    /// Undo option action.
    /**
     * @return  True if undo succeeded; otherwise false.
     */
    virtual bool undo (void) = 0;

  };

  /**
   * @class GoalOption
   *
   * @brief Class for objects that encode client command option to plan and
   *        deploy an opstring for a goal.
   */
  class GoalOption : public UIOption {
  public:
    /// Constructor.
    /**
     * @param descrip  Description of option for display in UI.
     *
     * @param undo_descrip  Description of undo option for display in UI.
     *
     * @param driver  Pointer to SA-POP driver to use during option invocation.
     *
     * @param goal  Goal to plan and deploy opstring when invoked.
     */
    GoalOption (std::string descrip, std::string undo_descrip,
      ::CIAO::RACE::SA_POP::Driver_ptr driver,
      ::CIAO::RACE::GoalStructure goal);

    /// Constructor for a goal with only goal conditions.
    /**
     * @param descrip  Description of option for display in UI.
     *
     * @param undo_descrip  Description of undo option for display in UI.
     *
     * @param driver  Pointer to SA-POP driver to use during option invocation.
     *
     * @param goal_conds  Map from goal conditions to utilities.
     */
    GoalOption (std::string descrip, std::string undo_descrip,
      ::CIAO::RACE::SA_POP::Driver_ptr driver,
      ::SA_POP::GoalMap goal_conds);

    /// Destructor.
    virtual ~GoalOption (void);



  protected:
    /// Goal structure for this option.
    ::CIAO::RACE::GoalStructure goal_;

    /// Invoke option action (plan and deploy opstring for goal).
    /**
     * @return  True if invocation succeeded; otherwise false.
     */
    virtual bool invoke (void);

    /// Undo option action (remove deployment plan).
    /**
     * @return  True if undo succeeded; otherwise false.
     */
    virtual bool undo (void);

    /// Create and set internal goal using specified goal conditions & defaults.
    /**
     * @param goal_conds  Map from goal condition IDs to utilities.
     */
    virtual void create_def_goal (const ::SA_POP::GoalMap goal_conds);
  };

  /**
   * @class DeployOption
   *
   * @brief Class for objects that encode client command option to deploy
   *        a static deployment plan.
   */
  class DeployOption : public UIOption {
  public:
    /// Constructor.
    /**
     * @param descrip  Description of option for display in UI.
     *
     * @param undo_descrip  Description of undo option for display in UI.
     *
     * @param driver  Pointer to SA-POP driver to use during option invocation.
     *
     * @param dp_uri  URI of deployment plan.
     */
    DeployOption (std::string descrip, std::string undo_descrip,
      ::CIAO::RACE::SA_POP::Driver_ptr driver,
      std::string dp_uri);

    /// Destructor.
    virtual ~DeployOption (void);

  protected:
    /// URI of deployment plan for this option.
    std::string dp_uri_;

    /// Invoke option action (plan and deploy opstring for goal).
    /**
     * @return  True if invocation succeeded; otherwise false.
     */
    virtual bool invoke (void);

    /// Undo option action (remove deployment plan).
    /**
     * @return  True if undo succeeded; otherwise false.
     */
    virtual bool undo (void);
  };


};  /* SA_POP namespace */

#endif /* SA_POP_UI_OPTION_H_ */