Project

General

Profile

Revision 629

Added by Jason knichel about 16 years ago

added some more documentation

View differences:

Command.cpp
24 24

  
25 25
using namespace std;
26 26

  
27
/**
28
 * @brief Constructor for the Command class
29
 * 
30
 * @param connection_pool_temp The connection pool this instance of the Command class is supposed to use
31
 * @param cs The ColonetServer this instance of the Command class is supposed to use
32
 */
27 33
Command::Command(ConnectionPool * connection_pool_temp, ColonetServer* cs) {
28 34
  connection_pool = connection_pool_temp;
29 35
  colonet_server = cs;
30 36
}
31 37

  
38
/**
39
 * @brief Destructor for the Command class
40
 */
32 41
Command::~Command() {}
33 42

  
34 43
/**
35
* Called by connection pool to parse command from client.
36
*/
44
 * @brief Called by connection pool to parse command from client.
45
 *
46
 * @param command The command to parse
47
 * @param pool_index The index in the connection pool of the client who generated this command
48
 *
49
 * @return 0 on success, negative error code on failure
50
 */
37 51
int Command::parse_command(char* command, int pool_index) {
38 52
  char tokens[MAX_TOKENS][MAX_TOKEN_SIZE];
39 53
  int number_tokens = 0;
......
87 101
    return -1;
88 102
  }
89 103

  
104
  //look for the end of the next token (tokens are separated by spaces)
90 105
  while ((end_token = strstr(next_token, " "))) {
106
    //set the location of the space to a null terminator
91 107
    *end_token = '\0';
92 108

  
109
    //make sure the token isn't too long
93 110
    if (strlen(next_token) > MAX_TOKEN_SIZE-1) {
94 111
      return -1;
95 112
    }
96 113

  
114
    //copy the next token into the token array
97 115
    strcpy(tokens[number_tokens], next_token);
98 116

  
99 117
    number_tokens++;
118

  
100 119
    next_token = end_token + 1;
101 120

  
121
    //skip over extra whitespace if there is any between tokens
102 122
    while (isspace(*next_token) && *next_token != '\0') {
103 123
      next_token++;
104 124
    }
105 125
  }
106 126

  
127
  //get the last token if there were no spaces at the end of the string to indicate an end of token
107 128
  if (end_token == NULL && *next_token != '\0') {
108 129
    if (strlen(next_token) > MAX_TOKEN_SIZE-1) {
109 130
      return -1;
......
144 165
  return 0;
145 166
}
146 167

  
168
//TODO: fill in the doxygen comments for this
147 169
/**
148 170
* @brief Sends parsed command from server to robot(s).
171
*
172
* @param number_int_tokens 
173
* @param tokens
174
* @param pool_index
175
*
176
* @return 0 on success, negative error code on failure
149 177
*/
150 178
int Command::parse_send_to_robot(int number_int_tokens, char tokens[MAX_TOKENS][MAX_TOKEN_SIZE], int pool_index) {
151 179
  unsigned char int_tokens[MAX_TOKENS], arguments[PACKET_DATA_LEN];
......
185 213
}
186 214

  
187 215
/**
188
* 
189
*/
216
 * 
217
 */
190 218
int Command::parse_request_from_server(int number_tokens, char tokens[MAX_TOKENS][MAX_TOKEN_SIZE], int pool_index) {
191 219
  char* end_pointer = NULL;
192 220

  

Also available in: Unified diff