Changeset 6750bcd
- Timestamp:
- Sep 25, 2020, 6:12:27 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 91fb850
- Parents:
- 73fbe91
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/thierry_delisle_PhD/code/readQ_example/proto-gui/main.cpp
r73fbe91 r6750bcd 7 7 #include <memory> 8 8 #include <vector> 9 10 #include <getopt.h> 9 11 10 12 //-------------------- … … 172 174 173 175 174 int main( ) {176 int main(int argc, char * argv[]) { 175 177 nframes = 3; 176 178 fsize = 1000; 177 179 nproduce = 60; 180 181 for(;;) { 182 static struct option options[] = { 183 {"buff", required_argument, 0, 'b'}, 184 {"nprod", required_argument, 0, 'p'}, 185 {"fsize", required_argument, 0, 'f'}, 186 {0, 0, 0, 0} 187 }; 188 189 int idx = 0; 190 int opt = getopt_long(argc, argv, "b:p:f:", options, &idx); 191 192 std::string arg = optarg ? optarg : ""; 193 size_t len = 0; 194 switch(opt) { 195 // Exit Case 196 case -1: 197 /* paranoid */ assert(optind <= argc); 198 goto run; 199 case 'b': 200 try { 201 nframes = std::stoul(optarg, &len); 202 if(nframes == 0 || len != arg.size()) { throw std::invalid_argument(""); } 203 } catch(std::invalid_argument &) { 204 std::cerr << "Number of buffered frames must be at least 1, was" << arg << std::endl; 205 goto usage; 206 } 207 break; 208 case 'p': 209 try { 210 nproduce = std::stoul(optarg, &len); 211 if(nproduce == 0 || len != arg.size()) { throw std::invalid_argument(""); } 212 } catch(std::invalid_argument &) { 213 std::cerr << "Number of produced frames must be at least 1, was" << arg << std::endl; 214 goto usage; 215 } 216 break; 217 case 'f': 218 try { 219 fsize = std::stoul(optarg, &len); 220 if(fsize == 0 || len != arg.size()) { throw std::invalid_argument(""); } 221 } catch(std::invalid_argument &) { 222 std::cerr << "Size of produced frames must be at least 1, was" << arg << std::endl; 223 goto usage; 224 } 225 break; 226 // Other cases 227 default: /* ? */ 228 std::cerr << opt << std::endl; 229 usage: 230 std::cerr << "Usage: " << argv[0] << " [options]" << std::endl; 231 std::cerr << std::endl; 232 std::cerr << " -b, --buff=COUNT Number of frames to buffer" << std::endl; 233 std::cerr << " -p, --nprod=COUNT Number of frames to produce" << std::endl; 234 std::cerr << " -f, --fsize=SIZE Size of each frame in bytes" << std::endl; 235 std::exit(1); 236 } 237 } 238 run: 178 239 179 240 frames.reset(new Frame[nframes]); … … 182 243 frames[i].data.reset(new unsigned char[fsize]); 183 244 } 184 std::cout << "Created frames" << std::endl; 245 std::cout << "Created frames of " << fsize << " bytes" << std::endl; 246 std::cout << "(Buffering " << nframes << ")" << std::endl; 185 247 186 248 thrdlib_setproccnt( 2 );
Note: See TracChangeset
for help on using the changeset viewer.