MessageClass.hpp
Go to the documentation of this file.
1 /*----------------------------------------------------------------------------*/
2 /* */
3 /* Copyright (c) 1995, 2004 IBM Corporation. All rights reserved. */
4 /* Copyright (c) 2005-2009 Rexx Language Association. All rights reserved. */
5 /* */
6 /* This program and the accompanying materials are made available under */
7 /* the terms of the Common Public License v1.0 which accompanies this */
8 /* distribution. A copy is also available at the following address: */
9 /* http://www.oorexx.org/license.html */
10 /* */
11 /* Redistribution and use in source and binary forms, with or */
12 /* without modification, are permitted provided that the following */
13 /* conditions are met: */
14 /* */
15 /* Redistributions of source code must retain the above copyright */
16 /* notice, this list of conditions and the following disclaimer. */
17 /* Redistributions in binary form must reproduce the above copyright */
18 /* notice, this list of conditions and the following disclaimer in */
19 /* the documentation and/or other materials provided with the distribution. */
20 /* */
21 /* Neither the name of Rexx Language Association nor the names */
22 /* of its contributors may be used to endorse or promote products */
23 /* derived from this software without specific prior written permission. */
24 /* */
25 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
26 /* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
27 /* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
28 /* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */
29 /* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
30 /* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */
31 /* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */
32 /* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY */
33 /* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
34 /* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
35 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
36 /* */
37 /*----------------------------------------------------------------------------*/
38 /******************************************************************************/
39 /* REXX Kernel MessageClass.hpp */
40 /* */
41 /* Primitive Message Class Definitions */
42 /* */
43 /******************************************************************************/
44 #ifndef Included_RexxMessage
45 #define Included_RexxMessage
46 
47 #define flagResultReturned 0x00000001
48 #define flagRaiseError 0x00000002
49 #define flagErrorReported 0x00000004
50 #define flagAllNotified 0x00000008
51 #define flagStartPending 0x00000010
52 #define flagMsgSent 0x00000020
53 
54  class RexxMessage : public RexxObject {
55  public:
56  void * operator new(size_t);
57  inline void * operator new(size_t size, void *objectPtr) { return objectPtr; };
58  /* So it doesn't need to do anythin*/
59  RexxMessage(RexxObject *, RexxString *, RexxObject *, RexxObject **, size_t, size_t);
60  inline RexxMessage(RESTORETYPE restoreType) : waitResultSem("RexxMessage::waitResultSem") { ; };
61 
62  void live(size_t);
63  void liveGeneral(int reason);
64  void flatten(RexxEnvelope *);
66  RexxObject *result();
70  void sendNotification();
71  void error(RexxDirectory *);
77  RexxObject *newRexx(RexxObject **, size_t, size_t);
79 
80  inline bool resultReturned() { return (this->dataFlags & flagResultReturned) != 0; };
81  inline bool raiseError() { return (this->dataFlags & flagRaiseError) != 0; };
82  inline bool errorReported() { return (this->dataFlags & flagErrorReported) != 0; };
83  inline bool allNotified() { return (this->dataFlags & flagAllNotified) != 0; };
84  inline bool startPending() { return (this->dataFlags & flagStartPending) != 0; };
85  inline bool msgSent() { return (this->dataFlags & flagMsgSent) != 0; };
86  inline void setResultReturned() { this->dataFlags |= flagResultReturned; };
87  inline void setRaiseError() { this->dataFlags |= flagRaiseError; };
88  inline void setErrorReported() { this->dataFlags |= flagErrorReported; };
89  inline void setAllNotified() { this->dataFlags |= flagAllNotified; };
90  inline void setStartPending() { this->dataFlags |= flagStartPending; };
91  inline void setMsgSent() { this->dataFlags |= flagMsgSent; };
92 
93  static void createInstance();
95 
96  protected:
97 
98  RexxObject *receiver; /* Real receiver of message. */
99  RexxObject *target; /* Target object specified */
100  RexxString *message; /* Message to be sent */
101  RexxObject *startscope; /* Starting scope for method lookup */
102  // RexxArray *args;
104  RexxList *interestedParties; /* message objects to be notified */
105  RexxDirectory *condition; /* condition object, generated by */
106  RexxActivity *startActivity; /* Activity created to run msg */
107  RexxList *waitingActivities; /* waiting activities list */
108  size_t dataFlags; /* flags to control processing */
109  SysSemaphore waitResultSem; /* Semophore used to wait on result */
110  size_t NumWaiting; /* activities waiting on result */
111 
112  // Positional arguments from arglist[0] to arglist[argcount-1]
113  // Named arguments from arglist[argcount] to arglist[argcount + (2*named_argcount)-1]
114  RexxObject ** arglist; // list of positional & named arguments
115  size_t argcount; // count of positional arguments
116  size_t named_argcount; // count of named arguments
117  };
118 
119 #endif
#define flagErrorReported
#define flagResultReturned
#define flagAllNotified
#define flagStartPending
#define flagRaiseError
#define flagMsgSent
RESTORETYPE
Definition: ObjectClass.hpp:82
void flatten(RexxEnvelope *)
RexxString * messageName()
bool raiseError()
RexxObject * resultObject
void setMsgSent()
void liveGeneral(int reason)
RexxObject * receiver
RexxObject * completed()
RexxObject * target
size_t named_argcount
RexxObject * startscope
SysSemaphore waitResultSem
RexxString * message
void sendNotification()
RexxMessage(RESTORETYPE restoreType)
void setResultReturned()
RexxObject * messageTarget()
static void createInstance()
RexxObject * result()
RexxObject * newRexx(RexxObject **, size_t, size_t)
bool errorReported()
size_t dataFlags
RexxObject * notify(RexxMessage *)
void live(size_t)
RexxObject * start(RexxObject *)
bool startPending()
size_t NumWaiting
RexxDirectory * condition
RexxActivity * startActivity
RexxMessage(RexxObject *, RexxString *, RexxObject *, RexxObject **, size_t, size_t)
RexxActivity * getActivity()
RexxList * interestedParties
RexxObject ** arglist
RexxList * waitingActivities
bool allNotified()
void setErrorReported()
bool msgSent()
void setRaiseError()
void setAllNotified()
bool resultReturned()
void error(RexxDirectory *)
static RexxClass * classInstance
RexxArray * arguments()
RexxObject * send(RexxObject *)
RexxObject * hasError()
void setStartPending()
RexxObject * errorCondition()