Line data Source code
1 : // Copyright 2024 Accenture.
2 :
3 : #pragma once
4 :
5 : #include <uds/DiagReturnCode.h>
6 : #include <util/Mask.h>
7 :
8 : namespace uds
9 : {
10 : class ApplicationDefaultSession;
11 : class ApplicationExtendedSession;
12 : class ProgrammingSession;
13 :
14 : class DiagSession
15 : {
16 : public:
17 : enum
18 : {
19 : MAX_INDEX = 8
20 : };
21 :
22 : typedef Mask<DiagSession> DiagSessionMask;
23 :
24 : static ApplicationDefaultSession& APPLICATION_DEFAULT_SESSION();
25 : static ApplicationExtendedSession& APPLICATION_EXTENDED_SESSION();
26 : static ProgrammingSession& PROGRAMMING_SESSION();
27 :
28 : static DiagSessionMask const& ALL_SESSIONS();
29 : static DiagSessionMask const& APPLICATION_EXTENDED_SESSION_MASK();
30 :
31 : enum SessionType
32 : {
33 : DEFAULT = 0x01,
34 : PROGRAMMING = 0x02,
35 : EXTENDED = 0x03,
36 : };
37 :
38 : uint8_t toIndex() const { return fId; }
39 :
40 : uint8_t getSessionByte() const { return fType; }
41 :
42 : SessionType getType() const { return fType; }
43 :
44 : virtual DiagReturnCode::Type isTransitionPossible(DiagSession::SessionType targetSession) = 0;
45 :
46 : virtual DiagSession& getTransitionResult(DiagSession::SessionType targetSession) = 0;
47 :
48 0 : virtual void enter() {}
49 :
50 : protected:
51 : DiagSession(SessionType id, uint8_t index);
52 :
53 : private:
54 : SessionType fType;
55 : uint8_t fId;
56 : };
57 :
58 : bool operator==(DiagSession const& x, DiagSession const& y);
59 : bool operator!=(DiagSession const& x, DiagSession const& y);
60 :
61 : } // namespace uds
|