Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vsnet_parsecmd.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15  */
16 
17 #ifndef VSNET_PARSECMD_H
18 #define VSNET_PARSECMD_H
19 
20 #include "netbuffer.h"
21 #include "vsnet_dloadenum.h"
22 
23 namespace VsnetDownload
24 {
25 namespace Adapter
26 {
27 struct Base;
28 struct ResolveRequest;
29 struct ResolveResponse;
30 struct DownloadRequest;
31 struct DownloadError;
32 struct Download;
34 struct DownloadFragment;
37 };
38 
40 {
41 public: RecvCmdDownload( NetBuffer &buffer );
43 
44  Subcommand parse();
45 
47  {
48  return (Adapter::ResolveRequest*) _base;
49  }
51  {
52  return (Adapter::ResolveResponse*) _base;
53  }
55  {
56  return (Adapter::DownloadRequest*) _base;
57  }
59  {
60  return (Adapter::DownloadError*) _base;
61  }
62  inline Adapter::Download * asDownload() const
63  {
64  return (Adapter::Download*) _base;
65  }
67  {
68  return (Adapter::DownloadFirstFragment*) _base;
69  }
71  {
72  return (Adapter::DownloadFragment*) _base;
73  }
75  {
76  return (Adapter::DownloadLastFragment*) _base;
77  }
79  {
80  return (Adapter::UnexpectedSubcommand*) _base;
81  }
82 
83 private:
84  NetBuffer &_buf;
85  Adapter::Base *_base;
86 
89  RecvCmdDownload& operator=( const RecvCmdDownload& );
90 };
91 
92 namespace Adapter
93 {
94 struct Base
95 {
97 };
98 
99 struct ResolveRequest : public Base
100 {
101  struct entry
102  {
103  char ft;
104  string file;
105  };
106 
107  typedef vector< entry >::iterator iterator;
108 
109  short num;
110  vector< entry >files;
111 };
112 
113 struct ResolveResponse : public Base
114 {
115  struct entry
116  {
117  string file;
118  char ok;
119  };
120 
121  typedef vector< entry >::iterator iterator;
122 
123  short num;
124  vector< entry >files;
125 };
126 
127 struct DownloadRequest : public Base
128 {
129  struct entry
130  {
131  char ft;
132  string file;
133  };
134 
135  typedef vector< entry >::iterator iterator;
136 
137  short num;
138  vector< entry >files;
139 };
140 
141 struct DownloadError : public Base
142 {
143  string file;
144 };
145 
146 struct Download : public Base
147 {
148  string file;
149  short payload_len;
150  unsigned char *payload;
151 };
152 
154 {
155  string file;
156  int file_len;
157  short payload_len;
158  unsigned char *payload;
159 };
160 
161 struct DownloadFragment : public Base
162 {
163  short payload_len;
164  unsigned char *payload;
165 };
166 
167 struct DownloadLastFragment : public Base
168 {
169  short payload_len;
170  unsigned char *payload;
171 };
172 
173 struct UnexpectedSubcommand : public Base
174 {};
175 }; //Adapter
176 }; //VsnetDownload
177 
178 #endif
179