C++ TargetRTS
Loading...
Searching...
No Matches
RTProtocol.h
1/*
2 * Licensed Materials - Property of HCL and/or IBM
3 * Copyright HCL Technologies Ltd. 2016, 2021. All Rights Reserved.
4 * Copyright IBM Corporation 1999, 2016. All Rights Reserved.
5 *
6 * U.S. Government Users Restricted Rights - Use, duplication or
7 * disclosure restricted by GSA ADP Schedule.
8 */
9
10#ifndef __RTProtocol_h__
11#define __RTProtocol_h__ included
12
13#ifdef PRAGMA
14#pragma interface
15#endif
16
17#ifndef __RTPriority_h_
18#include <RTPriority.h>
19#endif
20
21#ifndef __RTProtocolDescriptor_h__
22#include <RTProtocolDescriptor.h>
23#endif
24
25class RTActor;
26class RTActorProbe;
27struct RTBindingEnd;
28class RTController;
29class RTDebugger;
31struct RTInSignal;
33class RTLayerData;
34class RTMessage;
35struct RTObject_class;
36struct RTOutSignal;
37struct RTPortDescriptor;
39struct RTTypedValue;
40
50{
51public:
52 RTS_INLINE RTProtocol( void );
53 ~RTProtocol( void );
54
58 RTController * context( void ) const;
59
63 RTS_INLINE int getId( void ) const;
64
70 const RTPortDescriptor * getInfo( void ) const;
71
75 RTS_INLINE const char * getName( void ) const;
76
80 RTS_INLINE RTActor * getOwner( void ) const;
81
87 RTS_INLINE int size( void ) const;
88
96 int resize( int new_size );
97
108 RTS_INLINE int registerSAP( const char * service);
109
114 RTS_INLINE int deregisterSAP( void );
115
126 RTS_INLINE int registerSPP( const char * service);
127
132 RTS_INLINE int deregisterSPP( void );
133
138 const char * defaultLayerName( void ) const;
139
143 RTS_INLINE int isRegistered( void ) const;
144
149 const char * getRegisteredName( void ) const;
150
151#if RTS_COMPATIBLE <= 520
157 int registerAs( const char * service);
158#endif
159
164 int deregister( void );
165
171 int isBoundAt( int index ) const;
172
180 int isIndexTo( int index, RTActor * capsule) const;
181
189 int indexTo( RTActor * capsule) const;
190
191 // Managing the defer queue: These functions match any signal.
192
197 int purge( void );
198
203 int purgeAt( int index );
204
209 int recall( void );
210
215 int recallFront( void );
216
225 int recallAt( int index, int front = 0 );
226
232 int recallAll( void );
233
239 int recallAllFront( void );
240
249 int recallAllAt( int index, int front = 0 );
250
260 void bindingNotification( int on_off );
261
265 RTS_INLINE int bindingNotificationRequested( void ) const;
266
275 void sendTypeCheckEnable( int on_off );
276
280 RTS_INLINE int sendTypeCheckEnabled( void ) const;
281
292 RTProtocolDescriptor::Status sendCheck( int signal, const RTObject_class * type ) const;
293
302 void receiveTypeCheckEnable( int on_off );
303
307 RTS_INLINE int receiveTypeCheckEnabled( void ) const;
308
319 RTProtocolDescriptor::Status receiveCheck( int signal, const RTObject_class * type ) const;
320
321protected:
322 enum
323 {
324 BindingNotification = 1
325 , RegisteredAsSAP = 2
326 , SendTypeCheck = 4
327 , ReceiveTypeCheck = 8
328 , Resized = 16
329 };
330
331 void init( const RTPortDescriptor * );
332
333 RTS_INLINE int getFlags( void ) const;
334 void setFlag( int );
335 void resetFlag( int );
336
337 void bindAt( int, RTBindingEnd &, RTController * );
338 int peerAt( int, RTBindingEnd & );
339 void unbindAt( int, RTController * );
340
341 void notifyInit( RTController * );
342 void notifyBoundAt( int, RTController * );
343
344 // Derived classes define additional incoming signals starting
345 // with ( rtiLast_{BASE} + 1 ) and will define rtiLast_{CLASS}
346 // as its last signal.
347 enum
348 {
349 rtiLast_RTProtocol = 0
350 };
351
352private:
353 // Represents a port instance
354 struct End
355 {
356 enum State
357 {
358 Unbound,
359 Bound,
360 BoundXThread
361 };
362
363 State state;
364 RTProtocol * remote;
365 int remoteIndex;
366 const int * signalMap;
367
368 // these are only called after the priority and type are checked
369
370 int send( RTController * sender,
371 RTProtocol * port,
372 int index,
373 int signal,
374 const void * data,
375 const RTObject_class * type,
376 int prio,
377 bool moveData );
378
379 int invoke( RTMessage * replyBuffer,
380 RTController * invoker,
381 RTProtocol * port,
382 int index,
383 int signal,
384 const void * data,
385 const RTObject_class * type,
386 bool implicitReply);
387 };
388
389 End * _ends;
390 const RTPortDescriptor * _info;
391 int _flags;
392 RTLayerData * _layer;
393
394 // unavailable methods
395 RTProtocol( const RTProtocol & );
396 RTProtocol & operator=( const RTProtocol & );
397
398 friend struct End;
399 friend class RTActor;
400 friend class RTActorProbe;
401 friend class RTDebugger;
402 friend class RTLayerConnector;
403
404 enum CallStyle { Programmatic, Automatic };
405
406 int registerSAP( const char *, CallStyle );
407 int deregisterSAP( CallStyle );
408
409 int registerSPP( const char *, CallStyle );
410 int deregisterSPP( CallStyle );
411
412 // These classes must have access to the methods below.
413 friend struct RTExceptionSignal;
414 friend struct RTInSignal;
415 friend struct RTOutSignal;
416 friend struct RTSymmetricSignal;
417
418 // support for "in" signals
419
420 int purge ( int signal );
421 int purgeAt ( int signal, int index );
422
423 int recall ( int signal, int front );
424 int recallAt ( int signal, int index, int front );
425
426 int recallAll ( int signal, int front );
427 int recallAllAt( int signal, int index, int front );
428
429public:
430 // support for "out" signals
431 // These need to be public to support programmatic invoke, reply and send on a general port based on descriptor info
432
448 int invoke( RTMessage * replyBuffer,
449 int signal,
450 const void * data,
451 const RTObject_class * type,
452 bool implicitReply);
453
471 int invokeAt( int index,
472 RTMessage * replyBuffer,
473 int signal,
474 const void * data,
475 const RTObject_class * type,
476 bool implicitReply);
477
487 int reply( int signal,
488 const void * data,
489 const RTObject_class * type );
490
504 int send( int signal,
505 const void * data,
506 const RTObject_class * type,
507 int priority,
508 bool moveData = false);
509
525 int sendAt( int index,
526 int signal,
527 const void * data,
528 const RTObject_class * type,
529 int priority,
530 bool moveData = false);
531
532private:
533 // support for "exception" signals
534 int raise( int signal,
535 const void * data,
536 const RTObject_class * type );
537};
538
539#if RTS_INLINES
540#include <RTProtocol.inl>
541#endif
542
543#endif // __RTProtocol_h__
An instance of this class represents a capsule instance.
Definition: RTActor.h:44
Definition: RTActorProbe.h:31
A controller manages a group of capsule instances that all run in the same physical thread (i....
Definition: RTController.h:54
Definition: RTDebugger.h:58
Definition: RTLayerConnector.h:34
Definition: RTLayerData.h:24
Represents a message used for communication between capsule instances.
Definition: RTMessage.h:33
Represents a general capsule port typed by a protocol which determines the set of events that can be ...
Definition: RTProtocol.h:50
RTController * context(void) const
Get the context of the capsule that owns this port.
const char * defaultLayerName(void) const
Get the default registration name for the port.
int size(void) const
Get the size of the port.
Definition: RTProtocol.inl:62
RTProtocolDescriptor::Status sendCheck(int signal, const RTObject_class *type) const
Check if a particular event would be possible to send on this port.
int purgeAt(int index)
Empty the defer queue of a specified port instance without recalling any deferred message.
int isRegistered(void) const
Determine if the port is currently registered with the layer service or not.
Definition: RTProtocol.inl:72
void sendTypeCheckEnable(int on_off)
Turn on or off type checking when performing send(), invoke() or reply() on the port.
const char * getRegisteredName(void) const
Get the registration name of the port.
int send(int signal, const void *data, const RTObject_class *type, int priority, bool moveData=false)
Send an event on the port.
int invoke(RTMessage *replyBuffer, int signal, const void *data, const RTObject_class *type, bool implicitReply)
Invoke an event on the port.
void bindingNotification(int on_off)
Turn on or off binding notifications for this port.
int deregisterSAP(void)
Deregister an unwired port (SAP).
Definition: RTProtocol.inl:97
int recallAllAt(int index, int front=0)
Recall all messages from the defer queue and insert them in the controller's message queue.
int reply(int signal, const void *data, const RTObject_class *type)
Make a reply to respond to an invoke.
int recallAllFront(void)
Recall all messages from the defer queue and insert them at the front of the controller's message que...
int receiveTypeCheckEnabled(void) const
Determine if type checking when receiving events is enabled.
Definition: RTProtocol.inl:87
int getId(void) const
Get the id of the port.
Definition: RTProtocol.inl:45
int recall(void)
Recall a message from the defer queue and insert it at the back of the controller's message queue (af...
int sendAt(int index, int signal, const void *data, const RTObject_class *type, int priority, bool moveData=false)
Send an event on a replicated port at a specified index.
int indexTo(RTActor *capsule) const
Determine if there exists a port instance currently connected to a port instance owned by a certain c...
int sendTypeCheckEnabled(void) const
Determine if type checking when sending events is enabled.
Definition: RTProtocol.inl:82
int purge(void)
Empty the defer queue of all port instances without recalling any deferred message.
int recallAt(int index, int front=0)
Recall a message from the defer queue and insert it in the controller's message queue.
RTProtocolDescriptor::Status receiveCheck(int signal, const RTObject_class *type) const
Check if a particular event would be possible to receive on this port.
int invokeAt(int index, RTMessage *replyBuffer, int signal, const void *data, const RTObject_class *type, bool implicitReply)
Invoke an event on a replicated port at a specified index.
int deregisterSPP(void)
Deregister an unwired port (SPP).
Definition: RTProtocol.inl:107
int registerSPP(const char *service)
Register an unwired port (SPP) with the layer service (as the "provider").
Definition: RTProtocol.inl:102
const RTPortDescriptor * getInfo(void) const
Get information about a port.
int isIndexTo(int index, RTActor *capsule) const
Determine if a port instance is currently connected to a port instance owned by a certain capsule ins...
void receiveTypeCheckEnable(int on_off)
Turn on or off type checking when receiving an event on the port.
int registerAs(const char *service)
Register an unwired port either as an SAP or SPP (depending on the "Publish" property of the port).
int bindingNotificationRequested(void) const
Determine if binding notifications are currently enabled for the port.
Definition: RTProtocol.inl:77
int isBoundAt(int index) const
Determine if a port instance is currently connected to another port instance.
int recallFront(void)
Recall a message from the defer queue and insert it at the front of the controller's message queue (b...
int deregister(void)
Deregister an unwired port (either an SAP or SPP).
const char * getName(void) const
Get the name of the port.
Definition: RTProtocol.inl:50
int resize(int new_size)
Set a new size (i.e.
int registerSAP(const char *service)
Register an unwired port (SAP) with the layer service (as a "client").
Definition: RTProtocol.inl:92
RTActor * getOwner(void) const
Get the owner capsule to which the port belongs.
Definition: RTProtocol.inl:55
int recallAll(void)
Recall all messages from the defer queue and insert them at the back of the controller's message queu...
Definition: RTBindingEnd.h:24
Definition: RTExceptionSignal.h:29
Provides the API for working with messages of a certain protocol event received on a certain port.
Definition: RTInSignal.h:34
A type descriptor providing information about a type.
Definition: RTObject_class.h:64
Provides the API for working with messages of a certain protocol event to be sent on a certain port,...
Definition: RTOutSignal.h:36
Definition: RTPortDescriptor.h:42
Provides the combined API of both RTOutSignal and RTInSignal for symmetric protocol events defined as...
Definition: RTSymmetricSignal.h:32
Encapsulates a data object and its type descriptor.
Definition: RTTypedValue.h:29