3
A brief file description
5
@section license License
7
Licensed to the Apache Software Foundation (ASF) under one
8
or more contributor license agreements. See the NOTICE file
9
distributed with this work for additional information
10
regarding copyright ownership. The ASF licenses this file
11
to you under the Apache License, Version 2.0 (the
12
"License"); you may not use this file except in compliance
13
with the License. You may obtain a copy of the License at
15
http://www.apache.org/licenses/LICENSE-2.0
17
Unless required by applicable law or agreed to in writing, software
18
distributed under the License is distributed on an "AS IS" BASIS,
19
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
See the License for the specific language governing permissions and
21
limitations under the License.
24
/***************************************/
25
/****************************************************************************
27
* Module: concrete class for comand line interface event handling
30
****************************************************************************/
32
#ifndef _CMDLINE_EVENTHANDLER_H
33
#define _CMDLINE_EVENTHANDLER_H
36
#include "AbsEventHandler.h" /* Abstract base class for event handler */
37
#include "TextBuffer.h"
39
/* Define list of possible command line states */
42
CL_BASE = 0, /* 1. Base command line */
43
CL_MONITOR, /* 2. Monitor mode */
44
CL_CONFIGURE, /* 3. Configuration mode */
45
CL_MON_DASHBOARD, /* 4. Monitor->Dashboard */
46
CL_MON_NODE, /* 5. Monitor->Node */
47
CL_MON_PROTOCOLS, /* 6. Monitor->Protocols */
48
CL_MON_CACHE, /* 7. Monitor->Cache */
49
CL_MON_OTHER, /* 8. Monitor->Other */
50
CL_CONF_SERVER, /* 9. Configure->Server */
51
CL_CONF_PROTOCOLS, /* 10. Configure->Protocols */
52
CL_CONF_CACHE, /* 11. Configure->Cache */
53
CL_CONF_SECURITY, /* 12. Configure->Security */
54
CL_CONF_HOSTDB, /* 13. Configure->Hostdb */
55
CL_CONF_LOGGING, /* 14. Configure->logging */
56
CL_CONF_SNAPSHOTS, /* 15. Configure->snapshots */
57
CL_CONF_ROUTING /* 16. Configure->routing */
61
/* Define list of possible events to command line */
62
enum cmdline_events /* 20 events */
64
/* INTERNAL_ERROR = 0, for unhandled events */
67
CL_EV_HELP, /* all levels */
68
CL_EV_EXIT, /* all levels */
69
CL_EV_PREV, /* all levels, BaseLevel should ignore */
70
CL_EV_GET, /* ?all levels? , only really used in batch mode */
71
CL_EV_SET, /* ?all levels? */
72
CL_EV_DISPLAY, /* ?all levels? */
74
CL_EV_QUERY_DEADHOSTS, /* only base level */
75
/* generic events based on option number - 11 */
76
CL_EV_ADD_ALARM, /* OEM_SUN custom alarm feature */
90
/* Event handlers indexes i.e. each state handles events */
93
Ind_InternalError, /* handle Internal Errors e.g. unhandled events */
96
Ind_MonitorDashboardLevel,
98
Ind_MonitorProtocolsLevel,
99
Ind_MonitorCacheLevel,
100
Ind_MonitorOtherLevel,
102
Ind_ConfigureServerLevel,
103
Ind_ConfigureProtocolsLevel,
104
Ind_ConfigureCacheLevel,
105
Ind_ConfigureSecurityLevel,
106
Ind_ConfigureHostDBLevel,
107
Ind_ConfigureLoggingLevel,
108
Ind_ConfigureSnapshotsLevel,
109
Ind_ConfigureRoutingLevel
113
/* data structure used to pass data to event handlers */
114
typedef struct CLIdata
116
char *cmdmode; /* command mode i.e. batch(b) or interactive(i) */
117
char *cmdprompt; /* what prompt should look like e.g '->' */
118
char *command; /* command string itself */
119
char *args; /* arugments passed to 'command' */
120
textBuffer *output; /* output buffer */
121
cmdline_events cevent; /* event */
122
int advui; /* which UI */
123
int featset; /* feature set */
126
/* Command Line event handling class derived from an abstract event handler class */
127
class CmdLine_EventHandler:public AbsEventHandler
131
char *cmdmode; /* command mode i.e. batch(b) or interactive(i) */
132
const char *cmdprompt; /* what prompt should look like e.g '->' */
133
const char *dcmdprompt; /* default prompt */
134
char *args; /* arugments passed to this level */
135
cmdline_states curr_state; /* current command line state */
137
/* Redefinition of the abstract base class's pure virtual function
138
* ref: AbsEvenhandler.h */
139
void FillHandlersArray(void);
141
/* Event handlers - make some actions associated with a transition */
142
bool handleInternalError(void *cdata);
143
bool BaseLevel(void *cdata);
144
bool MonitorLevel(void *cdata);
145
bool MonitorDashboardLevel(void *cdata);
146
bool MonitorProtocolsLevel(void *cdata);
147
bool MonitorNodeLevel(void *cdata);
148
bool MonitorCacheLevel(void *cdata);
149
bool MonitorOtherLevel(void *cdata);
150
bool ConfigureLevel(void *cdata);
151
bool ConfigureServerLevel(void *cdata);
152
bool ConfigureProtocolsLevel(void *cdata);
153
bool ConfigureCacheLevel(void *cdata);
154
bool ConfigureSecurityLevel(void *cdata);
155
bool ConfigureRoutingLevel(void *cdata);
156
bool ConfigureHostDBLevel(void *cdata);
157
bool ConfigureLoggingLevel(void *cdata);
158
bool ConfigureSnapshotsLevel(void *cdata);
160
/* copy constructor and assignment operator are private
161
* to prevent their use */
162
CmdLine_EventHandler(const CmdLine_EventHandler & rhs);
163
CmdLine_EventHandler & operator=(const CmdLine_EventHandler & rhs);
165
/* no default constructor */
166
CmdLine_EventHandler();
170
CmdLine_EventHandler(int inNumberTransitions, char *cmdm = NULL, char *cmdp = NULL, char *largs = NULL);
173
~CmdLine_EventHandler(void);
176
const char *command_prompt(); /* get prompt */
177
void command_prompt(const char *new_prompt); /* set prompt */
178
char *arguments(); /* get args */
179
void arguments(char *new_args); /* set args */
180
char *command_mode(); /* get command mode */
181
void command_mode(char *new_cmode); /* set command mode */
182
cmdline_states current_state(); /* get current state */
183
void current_state(cmdline_states new_state); /* set current state */
186
#endif /* _CMDLINE_EVENTHANDLER_H */