b311480e |
1 | -- Created on: 1992-03-19 |
2 | -- Created by: Stephan GARNAUD (ARM) |
3 | -- Copyright (c) 1992-1999 Matra Datavision |
4 | -- Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | -- |
6 | -- The content of this file is subject to the Open CASCADE Technology Public |
7 | -- License Version 6.5 (the "License"). You may not use the content of this file |
8 | -- except in compliance with the License. Please obtain a copy of the License |
9 | -- at http://www.opencascade.org and read it completely before using this file. |
10 | -- |
11 | -- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | -- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
13 | -- |
14 | -- The Original Code and all software distributed under the License is |
15 | -- distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | -- Initial Developer hereby disclaims all such warranties, including without |
17 | -- limitation, any warranties of merchantability, fitness for a particular |
18 | -- purpose or non-infringement. Please see the License for the specific terms |
19 | -- and conditions governing the rights and limitations under the License. |
20 | |
7fd59977 |
21 | |
7fd59977 |
22 | |
7fd59977 |
23 | |
24 | |
25 | |
26 | class MailBox from OSD |
27 | |
28 | ---Purpose: Establishes a mailbox with VMS-like-features and with |
29 | -- asynchronous functions. |
30 | -- The mail boxes are used to communicate asynchronously |
31 | -- between processes. |
32 | -- Basically MailBox facilities provide tools to communicate |
33 | -- between a client process and a server process. |
34 | -- The client process puts data/requests into the mail-box and |
35 | -- the server process gets these data/requests. In this context |
36 | -- client and server must run on the same machine. |
37 | -- Warning: On VMS, you need TMPMBX privilege. |
38 | |
39 | uses Function, SharedMemory, Error, AsciiString from TCollection |
40 | raises ConstructionError, NullObject, OSDError, ProgramError |
41 | |
42 | |
43 | is |
44 | Create returns MailBox; |
45 | ---Purpose: To be used with 'Open'. |
46 | -- It just allocates room for 'myName'. |
47 | -- This is for a client process. |
48 | ---Level: Advanced |
49 | |
50 | Create (name : AsciiString ; Size : Integer ; Async_function : Function) |
51 | returns MailBox |
52 | ---Purpose: Instantiates MailBox object with a name, size required |
53 | -- and a function to read mail boxes asynchronously. |
54 | -- Each process working with the same MailBox must use |
55 | -- a common known access : the mail-box's name. |
56 | -- |
57 | -- This is for a server process. |
58 | -- Raises ConstructionError when the name is not composed by |
59 | -- characters in range of ' ' .. '~'. |
60 | -- Raises NullObject when Async_function is a null function |
61 | -- pointer |
62 | -- Raises ProgramError when Size has a negative or null value. |
63 | ---Level: Advanced |
64 | raises ConstructionError, NullObject, ProgramError; |
65 | |
66 | Build (me : in out) is static; |
67 | ---Purpose: Builds (physically) <me> into system. |
68 | -- <me> is created and ready to run. |
69 | -- This can be seen as an asynchronous server. |
70 | ---Level: Advanced |
71 | |
72 | Open (me: out ; name : AsciiString ; Size : Integer) |
73 | ---Purpose: Opens mail box, and is ready to communicate with an |
74 | -- already created mailbox. |
75 | -- Raises NullObject when the name is a null string. |
76 | -- Raises ConstructionError when the name contains characters not |
77 | -- in range of ' '...'~'. |
78 | -- Raises ProgramError when the mail box has a null size. |
79 | -- This can be seen as a client. |
80 | ---Level: Advanced |
81 | raises ConstructionError, NullObject, ProgramError is static; |
82 | |
83 | Delete (me: out) |
84 | ---Purpose: Removes the mail box from system. |
85 | -- This is used only by server process ! |
86 | -- Raises ProgramError when the mail box is already deleted. |
87 | ---Level: Advanced |
88 | raises ProgramError is static; |
89 | |
90 | Write (me : in out; Message : AsciiString ; Length : Integer) |
91 | ---Purpose: Writes a message of specified length into mail box. |
92 | -- <Message> is used as a buffer, not as a common string. |
93 | -- So this can be not null terminated like a 'char *'. |
94 | -- This is why <Length> is useful. |
95 | -- Raises ProgramError when the length of the data is either |
96 | -- negative or zero. |
97 | -- |
98 | ---Level: Advanced |
99 | raises ProgramError is static; |
100 | |
101 | Failed (me) returns Boolean is static; |
102 | ---Purpose: Returns TRUE if an error occurs |
103 | ---Level: Advanced |
104 | |
105 | Reset (me : in out) is static; |
106 | ---Purpose: Resets error counter to zero |
107 | ---Level: Advanced |
108 | |
109 | Perror (me : in out) |
110 | ---Purpose: Raises OSD_Error |
111 | ---Level: Advanced |
112 | raises OSDError is static; |
113 | |
114 | Error (me) returns Integer is static; |
115 | ---Purpose: Returns error number if 'Failed' is TRUE. |
116 | ---Level: Advanced |
117 | |
118 | fields |
119 | myId : Integer; -- Mail box Identification |
120 | myName : AsciiString; -- Name of mail box |
121 | mySize : Integer; -- Size of data area |
122 | myFunc : Function; -- AST like function |
123 | myError: Error; |
124 | end MailBox from OSD; |
125 | |