GM6000 Digital Heater Controller Build: 16 (Branch = develop)
SDX-1330
Context_.h
Go to the documentation of this file.
1#ifndef Cpl_TShell_ContextApi_x_h_
2#define Cpl_TShell_ContextApi_x_h_
3/*-----------------------------------------------------------------------------
4* This file is part of the Colony.Core Project. The Colony.Core Project is an
5* open source project with a BSD type of licensing agreement. See the license
6* agreement (license.txt) in the top/ directory or on the Internet at
7* http://integerfox.com/colony.core/license.txt
8*
9* Copyright (c) 2014-2025 John T. Taylor
10*
11* Redistributions of the source code must retain the above copyright notice.
12*----------------------------------------------------------------------------*/
13/** @file */
14
16#include "Cpl/TShell/Security.h"
17#include "Cpl/TShell/Command.h"
18#include "Cpl/Container/SList.h"
19
20
21///
22namespace Cpl {
23///
24namespace TShell {
25
26/** This Private Namespace class defines a "Context" for a TShell command. The
27 Context provide common infrastructure, information, buffers, etc. that
28 facilitates interaction between the Command Processor and individual
29 commands. The application SHOULD NEVER directly access this interface.
30 */
31class Context_ : public ProcessorApi
32{
33public:
34 /// This method returns the list of implemented commands
36
37 /// Lookup a command by its verb. Returns a nullptr if the command is not found
38 virtual Command* findCommand( const char* verb, size_t verbLength ) noexcept = 0;
39
40public:
41 /// This method encodes and outputs the specified message/text. The method returns false if there was Output Stream error
42 virtual bool writeFrame( const char* text ) noexcept = 0;
43
44 /// Same as writeFrame(), but only outputs (at most) 'N' bytes as the content of the frame
45 virtual bool writeFrame( const char* text, size_t maxBytes ) noexcept = 0;
46
47
48public:
49 /** This method returns a working buffer for a command to format its
50 output prior to 'writing the frame'.
51 */
52 virtual Cpl::Text::String& getOutputBuffer() noexcept = 0;
53
54 /** A shared/common working buffer. The buffer is guaranteed to be large
55 enough hold any valid token from an input frame. The contents of
56 buffer is guaranteed to be empty/cleared.
57 */
58 virtual Cpl::Text::String& getTokenBuffer() noexcept = 0;
59
60 /** Same as getTokenBuffer(), except provides a second/separate token buffer
61 */
62 virtual Cpl::Text::String& getTokenBuffer2() noexcept = 0;
63
64
65public:
66 /** This method allows a command access to the input stream, i.e. consume
67 additional input data that is 'out-of-band' of the nominal newline
68 delineated command syntax.
69
70 Attempts to read the specified number of bytes from the stream into the
71 supplied buffer. The actual number of bytes read is returned via
72 'bytesRead'. Returns true if successful, or false if End-of-Stream
73 was encountered.
74 */
75 virtual bool oobRead( void* buffer, int numBytes, int& bytesRead ) noexcept = 0;
76
77public:
78 /** This method returns the 'logged user' permission level
79 */
80 virtual Security::Permission_T getUserPermissionLevel() const noexcept = 0;
81
82 /** This method is used to updated the 'logged user' permission level. The
83 method returns the previous value for the user's permission level.
84
85 NOTE: The program model is that all command implementations are well
86 behaved in that they do not indiscriminately call this method.
87 In practice only the 'user' command should every call this method!
88 */
89 virtual Security::Permission_T setUserPermissionLevel( Security::Permission_T newPermissionLevel ) noexcept = 0;
90
91
92public:
93 /// Virtual destructor
94 virtual ~Context_() {}
95};
96
97
98}; // end namespaces
99};
100#endif // end header latch
This template class implements a THREAD SAFE Ring Buffer.
Definition RingBufferMT.h:33
This class defines the interface for a TShell command.
Definition Command.h:32
This Private Namespace class defines a "Context" for a TShell command.
Definition Context_.h:32
virtual Cpl::Text::String & getTokenBuffer2() noexcept=0
Same as getTokenBuffer(), except provides a second/separate token buffer.
virtual bool oobRead(void *buffer, int numBytes, int &bytesRead) noexcept=0
This method allows a command access to the input stream, i.e.
virtual bool writeFrame(const char *text) noexcept=0
This method encodes and outputs the specified message/text. The method returns false if there was Out...
virtual Command * findCommand(const char *verb, size_t verbLength) noexcept=0
Lookup a command by its verb. Returns a nullptr if the command is not found.
virtual Cpl::Container::SList< Command > & getCommands() noexcept=0
This method returns the list of implemented commands.
virtual Security::Permission_T getUserPermissionLevel() const noexcept=0
This method returns the 'logged user' permission level.
virtual Cpl::Text::String & getTokenBuffer() noexcept=0
A shared/common working buffer.
virtual Security::Permission_T setUserPermissionLevel(Security::Permission_T newPermissionLevel) noexcept=0
This method is used to updated the 'logged user' permission level.
virtual Cpl::Text::String & getOutputBuffer() noexcept=0
This method returns a working buffer for a command to format its output prior to 'writing the frame'.
This class defines the interface a TShell Command Processor.
Definition ProcessorApi.h:33
This abstract defines the interface for validating a 'user login' for TShell.
Definition Security.h:31
The 'Cpl' namespace is the root name space for the Colony.
Definition Api16.h:20