summaryrefslogtreecommitdiff
path: root/ACE/ace/Method_Request.h
blob: 0833fe93dd61194a8079c451fb9c365782bbb808 (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
// -*- C++ -*-

//=============================================================================
/**
 *  @file    Method_Request.h
 *
 *  @author Andres Kruse <Andres.Kruse@cern.ch>
 *  @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
 */
//=============================================================================


#ifndef ACE_METHOD_REQUEST_H
#define ACE_METHOD_REQUEST_H

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

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

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

#include "ace/Global_Macros.h"

ACE_BEGIN_VERSIONED_NAMESPACE_DECL

/**
 * @class ACE_Method_Request
 *
 * @brief Reifies a method into a request.  Subclasses must provide
 * the necessary state and behavior.
 *
 * An ACE_Method_Request is inserted in an ACE_Activation_Queue,
 * where it is subsequently removed by a scheduler object (often
 * derived from ACE_Task), which invokes the @c call() method.
 *
 * This class is discussed in depth in the Active Object chapter
 * of POSA2.
 *
 * @sa ACE_Activation_Queue
 */
class ACE_Export ACE_Method_Request
{
public:
  /// Constructor.
  ACE_Method_Request (unsigned long priority = 0);

  /// Destructor.
  virtual ~ACE_Method_Request () = default;

  // = Accessors.
  /// Get priority.
  unsigned long priority () const;

  /// Set priority.
  /**
   * Priority values are user-defined. The default (set in the constructor)
   * is 0. The priority value is used in the ACE_Activation_Queue::enqueue()
   * method to order the method requests in the queue by priority.
   * 0 is the lowest priority.
   *
   * @param prio   unsigned long, the new priority value for this object.
   *
   * @sa ACE_Activation_Queue::enqueue
   */
  void priority (unsigned long prio);

  // = Invocation method (must be overridden by subclasses).
  /// Invoked by the scheduler to execute the request.
  /**
   * This method must be implemented by the subclass to perform the
   * desired actions.
   *
   * @return int; not interpreted by ACE. The scheduler class must
   *         decide the meaning of this return value and act on it
   *         if needed.
   */
  virtual int call (void) = 0;

private:
  ACE_Method_Request (const ACE_Method_Request &) = delete;
  void operator= (const ACE_Method_Request &) = delete;
  ACE_Method_Request (ACE_Method_Request &&) = delete;
  void operator= (ACE_Method_Request &&) = delete;

protected:
  /// The priority of the request.
  unsigned long priority_;
};

ACE_END_VERSIONED_NAMESPACE_DECL


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