Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
Console::Session Class Reference

Console session metadata. More...

Inheritance diagram for Console::Session:
StateFlowBase Executable Notifiable QMember Destructable

Public Member Functions

 Session (Service *service, int fd_in, int fd_out)
 Constructor.
 
 ~Session ()
 Desctructor.
 
- Public Member Functions inherited from StateFlowBase
void run () override
 Callback from the executor.
 
void notify () override
 Wakeup call arrived.
 
Serviceservice ()
 Return a pointer to the service I am bound to.
 
- Public Member Functions inherited from Executable
void test_deletion ()
 
- Public Member Functions inherited from QMember
void init ()
 Initiailize a QMember, in place of a public placement construction.
 

Private Member Functions

StateFlowBase::Action entry ()
 Entry point to the state machine.
 
StateFlowBase::Action process_read ()
 Process the incoming command line input.
 
StateFlowBase::Action exit_interactive ()
 Wait for completion of an interactive command in order to cleanup based on result.
 
CommandStatus callback (int argc, const char *argv[])
 Process a potential callback for a given command.
 
void prompt (FILE *fp)
 Print the standard prompt.
 
bool callback_result_process (CommandStatus status, const char *name)
 Process the result of the command callback.
 
 DISALLOW_COPY_AND_ASSIGN (Session)
 

Private Attributes

int fdIn
 input file descriptor of the session
 
int fdOut
 output file descriptor of the session
 
FILE * fp
 file pointer of session
 
char * line
 current line content
 
size_t line_size
 current max line size
 
size_t pos
 current line position
 
const char * args [MAX_ARGS]
 parsed argument list
 
StateFlowBase::StateFlowSelectHelper selectHelper
 metadata for waiting on the listen socket to become active
 
Commandcommand
 Command instance that we are currently acting on.
 

Additional Inherited Members

- Static Public Member Functions inherited from StateFlowBase
template<class T , typename... Args>
static void invoke_subflow_and_ignore_result (FlowInterface< Buffer< T > > *target_flow, Args &&... args)
 Calls a helper flow to perform some actions.
 
- Protected Types inherited from StateFlowBase
typedef Action(StateFlowBase::* Callback) ()
 State Flow callback prototype.
 
- Protected Member Functions inherited from StateFlowBase
 StateFlowBase (Service *service)
 Constructor.
 
 ~StateFlowBase ()
 Destructor.
 
void reset_flow (Callback c)
 Resets the flow to the specified state.
 
bool is_state (Callback c)
 
bool is_terminated ()
 
void start_flow (Callback c)
 Resets the flow to the specified state and starts it.
 
Action again ()
 Call the current state again via call_immediately.
 
Action exit ()
 Terminate current StateFlow activity.
 
Action delete_this ()
 Terminates the flow and deletes *this.
 
Action set_terminated ()
 Sets the flow to terminated state.
 
Action call_immediately (Callback c)
 Imediately call the next state upon return.
 
Action wait ()
 Wait for an asynchronous call.
 
Action wait_and_call (Callback c)
 Wait for resource to become available before proceeding to next state.
 
template<class T >
Action allocate_and_call (FlowInterface< Buffer< T > > *target_flow, Callback c, Pool *pool=nullptr)
 Allocates a buffer from a pool and proceed to the next state when allocation is successful.
 
Action allocate_and_call (Callback c, QAsync *queue)
 Allocates an entry from an asynchronous queue, and transitions to a state once the allocation is complete.
 
template<class T >
Buffer< T > * full_allocation_result (FlowInterface< Buffer< T > > *target_flow)
 Takes the result of the asynchronous allocation without resetting the object.
 
template<class T >
T * full_allocation_result (TypedQAsync< T > *queue)
 Takes the result of the asynchronous allocation without resetting the object.
 
template<class T >
void cast_allocation_result (T **member)
 Takes the result of the asynchronous allocation without resetting the object.
 
template<class T >
Buffer< T > * get_allocation_result (FlowInterface< Buffer< T > > *target_flow)
 Takes the result of the asynchronous allocation.
 
Action yield_and_call (Callback c)
 Place the current flow to the back of the executor, and transition to a new state after we get the CPU again.
 
Action yield ()
 Place the current flow to the back of the executor, and re-try the current state after we get the CPU again.
 
Action sleep_and_call (::Timer *timer, long long timeout_nsec, Callback c)
 Suspends execution of this control flow for a specified time.
 
template<class T , typename... Args>
Action invoke_subflow_and_wait (FlowInterface< Buffer< T > > *target_flow, Callback c, Args &&... args)
 Calls a helper flow to perform some actions.
 
Action read_repeated (StateFlowSelectHelper *helper, int fd, void *buf, size_t size, Callback c, unsigned priority=Selectable::MAX_PRIO)
 Blocks until size bytes are read and then invokes the next state.
 
Action read_single (StateFlowSelectHelper *helper, int fd, void *buf, size_t size, Callback c, unsigned priority=Selectable::MAX_PRIO)
 Attempts to read at most size_t bytes, and blocks the caller until at least one byte is read.
 
Action read_nonblocking (StateFlowSelectHelper *helper, int fd, void *buf, size_t size, Callback c, unsigned priority=Selectable::MAX_PRIO)
 Attempts to read at most size bytes, and then invokes the next state, even if only zero bytes are available right now.
 
Action read_repeated_with_timeout (StateFlowTimedSelectHelper *helper, long long timeout_nsec, int fd, void *buf, size_t size, Callback c, unsigned priority=Selectable::MAX_PRIO)
 Blocks until size bytes are read, or a timeout expires.
 
Action internal_try_read ()
 Implementation state that gets repeatedly called upon every wakeup and tries to make progress on reading.
 
Action write_repeated (StateFlowSelectHelper *helper, int fd, const void *buf, size_t size, Callback c, unsigned priority=Selectable::MAX_PRIO)
 Writes some data into a file descriptor, repeating the operation as necessary until all bytes are written.
 
Action internal_try_write ()
 Implementation state that gets repeatedly called upon every wakeup and tries to make progress on writing.
 
- Protected Member Functions inherited from QMember
 QMember ()
 Constructor.
 
 ~QMember ()
 Destructor.
 
- Protected Attributes inherited from QMember
QMembernext
 pointer to the next member in the queue
 

Detailed Description

Console session metadata.

Definition at line 353 of file Console.hxx.

Constructor & Destructor Documentation

◆ Session()

Console::Session::Session ( Service service,
int  fd_in,
int  fd_out 
)

Constructor.

Parameters
serviceservice instance that this session belongs to
fd_ininput file descriptor for the session
fd_outoutput file descriptor for the session

Definition at line 260 of file Console.cxx.

◆ ~Session()

Console::Session::~Session ( )
inline

Desctructor.

Definition at line 365 of file Console.hxx.

Member Function Documentation

◆ callback()

Console::CommandStatus Console::Session::callback ( int  argc,
const char *  argv[] 
)
private

Process a potential callback for a given command.

Parameters
argcnumber of arguments including the command itself
argvarray of arguments starting with the command itself
Returns
status of the callback being called

Definition at line 379 of file Console.cxx.

◆ callback_result_process()

bool Console::Session::callback_result_process ( CommandStatus  status,
const char *  name 
)
private

Process the result of the command callback.

Parameters
statusthe result of running a command
namename of the command itself
Returns
false to close the session, else true

Definition at line 428 of file Console.cxx.

◆ entry()

StateFlowBase::Action Console::Session::entry ( )
inlineprivate

Entry point to the state machine.

Read some command line input.

Returns
next state is process_read()

Definition at line 382 of file Console.hxx.

◆ exit_interactive()

StateFlowBase::Action Console::Session::exit_interactive ( )
private

Wait for completion of an interactive command in order to cleanup based on result.

Returns
next state is entry()

Definition at line 408 of file Console.cxx.

◆ process_read()

StateFlowBase::Action Console::Session::process_read ( )
private

Process the incoming command line input.

Returns
next state is entry() to gather more data, exit_interactive() if an interactive command is called.
Todo:
quoted arguments not yet supported

Definition at line 278 of file Console.cxx.

◆ prompt()

void Console::Session::prompt ( FILE *  fp)
inlineprivate

Print the standard prompt.

Parameters
fpFILE pointer to send prompt to

Definition at line 410 of file Console.hxx.

Member Data Documentation

◆ args

const char* Console::Session::args[MAX_ARGS]
private

parsed argument list

Definition at line 429 of file Console.hxx.

◆ command

Command* Console::Session::command
private

Command instance that we are currently acting on.

Definition at line 435 of file Console.hxx.

◆ fdIn

int Console::Session::fdIn
private

input file descriptor of the session

Definition at line 423 of file Console.hxx.

◆ fdOut

int Console::Session::fdOut
private

output file descriptor of the session

Definition at line 424 of file Console.hxx.

◆ fp

FILE* Console::Session::fp
private

file pointer of session

Definition at line 425 of file Console.hxx.

◆ line

char* Console::Session::line
private

current line content

Definition at line 426 of file Console.hxx.

◆ line_size

size_t Console::Session::line_size
private

current max line size

Definition at line 427 of file Console.hxx.

◆ pos

size_t Console::Session::pos
private

current line position

Definition at line 428 of file Console.hxx.

◆ selectHelper

StateFlowBase::StateFlowSelectHelper Console::Session::selectHelper
private

metadata for waiting on the listen socket to become active

Definition at line 432 of file Console.hxx.


The documentation for this class was generated from the following files: