Ernesto Posse | 8a4f296 | 2015-05-12 13:28:46 -0400 | [diff] [blame] | 1 | // umlrtcapsule.hh |
| 2 | |
| 3 | /******************************************************************************* |
| 4 | * Copyright (c) 2014-2015 Zeligsoft (2009) Limited and others. |
| 5 | * All rights reserved. This program and the accompanying materials |
| 6 | * are made available under the terms of the Eclipse Public License v1.0 |
| 7 | * which accompanies this distribution, and is available at |
| 8 | * http://www.eclipse.org/legal/epl-v10.html |
| 9 | *******************************************************************************/ |
| 10 | |
| 11 | #ifndef UMLRTCAPSULE_HH |
| 12 | #define UMLRTCAPSULE_HH |
| 13 | |
| 14 | #include "umlrtcommsport.hh" |
| 15 | #include "umlrtcontroller.hh" |
| 16 | #include "umlrtcapsulerole.hh" |
| 17 | #include "umlrtcapsuletocontrollermap.hh" |
Barry Maher | f925261 | 2015-05-31 11:33:20 -0400 | [diff] [blame^] | 18 | #include "umlrtmessage.hh" |
Ernesto Posse | 8a4f296 | 2015-05-12 13:28:46 -0400 | [diff] [blame] | 19 | #include "umlrtslot.hh" |
| 20 | |
| 21 | // This is the base class for each generated capsule that is defined in the model. |
| 22 | |
| 23 | // It will have the implementation of the state machine and will include data |
| 24 | // like the current state. |
| 25 | |
| 26 | // Sub-classes define the model's capsules and contain user-defined and methods. |
| 27 | |
| 28 | struct UMLRTSlot; |
| 29 | struct UMLRTMessage; |
| 30 | struct UMLRTController; |
| 31 | struct UMLRTCapsuleClass; |
| 32 | class UMLRTRtsInterface; |
| 33 | |
| 34 | class UMLRTCapsule |
| 35 | { |
| 36 | public: |
| 37 | virtual ~UMLRTCapsule ( ); |
| 38 | virtual void initialize ( const UMLRTMessage & msg ) = 0; |
| 39 | virtual void inject ( const UMLRTMessage & msg ) = 0; |
| 40 | virtual void unbindPort ( bool isBorder, int portIndex, int farEndIndex ); |
| 41 | virtual void bindPort ( bool isBorder, int portIndex, int farEndIndex ); |
Barry Maher | f925261 | 2015-05-31 11:33:20 -0400 | [diff] [blame^] | 42 | virtual void unexpectedMessage ( ) const; |
| 43 | virtual const char * getCurrentStateString ( ) const { return ""; } |
Ernesto Posse | 8a4f296 | 2015-05-12 13:28:46 -0400 | [diff] [blame] | 44 | |
| 45 | const UMLRTCommsPort * * getBorderPorts ( ) const { return borderPorts; } |
| 46 | const UMLRTCommsPort * getInternalPorts ( ) const { return internalPorts; } |
| 47 | UMLRTSlot * getSlot ( ) const { return slot; } |
Barry Maher | f925261 | 2015-05-31 11:33:20 -0400 | [diff] [blame^] | 48 | const char * getName ( ) const { return slot->name; } |
| 49 | size_t getIndex ( ) const { return slot->capsuleIndex; } |
| 50 | UMLRTController::Error getError ( ) const { return context()->getError(); } |
Ernesto Posse | 8a4f296 | 2015-05-12 13:28:46 -0400 | [diff] [blame] | 51 | const UMLRTCapsuleClass * getClass ( ) const { return capsuleClass; } |
Barry Maher | f925261 | 2015-05-31 11:33:20 -0400 | [diff] [blame^] | 52 | const UMLRTMessage * getMsg ( ) const { return msg; } |
| 53 | |
| 54 | const UMLRTMessage * msg; |
Ernesto Posse | 8a4f296 | 2015-05-12 13:28:46 -0400 | [diff] [blame] | 55 | |
| 56 | protected: |
| 57 | |
| 58 | // User can get the controller e.g. for incarnation or getting the last error. |
| 59 | UMLRTController * context ( ) const { return slot->controller; } |
| 60 | |
| 61 | UMLRTCapsule ( const UMLRTRtsInterface * rtsif, const UMLRTCapsuleClass * capsuleClass, UMLRTSlot * slot, const UMLRTCommsPort * * borderPorts_, const UMLRTCommsPort * internalPorts_, bool isStatic_ ); |
| 62 | |
| 63 | const UMLRTRtsInterface * rtsif; |
| 64 | const UMLRTCapsuleClass * capsuleClass; |
| 65 | UMLRTSlot * const slot; |
| 66 | const UMLRTCommsPort * * borderPorts; |
| 67 | const UMLRTCommsPort * internalPorts; // Capsule's internal ports. Each of these may be replicated. |
| 68 | bool isStatic; // Keep this until we've soak-tested incarnate/destroy + import/deport. |
| 69 | }; |
| 70 | |
| 71 | #endif // UMLRTCAPSULE_HH |