blob: 00543ee46ecf628a11ee5450cee7f2b13b823a8c [file] [log] [blame]
Ernesto Posse8a4f2962015-05-12 13:28:46 -04001// 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 Maherf9252612015-05-31 11:33:20 -040018#include "umlrtmessage.hh"
Ernesto Posse8a4f2962015-05-12 13:28:46 -040019#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
28struct UMLRTSlot;
29struct UMLRTMessage;
30struct UMLRTController;
31struct UMLRTCapsuleClass;
32class UMLRTRtsInterface;
33
34class UMLRTCapsule
35{
36public:
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 Maherf9252612015-05-31 11:33:20 -040042 virtual void unexpectedMessage ( ) const;
43 virtual const char * getCurrentStateString ( ) const { return ""; }
Ernesto Posse8a4f2962015-05-12 13:28:46 -040044
45 const UMLRTCommsPort * * getBorderPorts ( ) const { return borderPorts; }
46 const UMLRTCommsPort * getInternalPorts ( ) const { return internalPorts; }
47 UMLRTSlot * getSlot ( ) const { return slot; }
Barry Maherf9252612015-05-31 11:33:20 -040048 const char * getName ( ) const { return slot->name; }
49 size_t getIndex ( ) const { return slot->capsuleIndex; }
50 UMLRTController::Error getError ( ) const { return context()->getError(); }
Ernesto Posse8a4f2962015-05-12 13:28:46 -040051 const UMLRTCapsuleClass * getClass ( ) const { return capsuleClass; }
Barry Maherf9252612015-05-31 11:33:20 -040052 const UMLRTMessage * getMsg ( ) const { return msg; }
53
54 const UMLRTMessage * msg;
Ernesto Posse8a4f2962015-05-12 13:28:46 -040055
56protected:
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