test_prog.cxx 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // Filename: test_prog.cxx
  2. // Created by: drose (14Feb00)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
  8. //
  9. // All use of this software is subject to the terms of the Panda 3d
  10. // Software license. You should have received a copy of this license
  11. // along with this source code; you will also find a current copy of
  12. // the license at http://etc.cmu.edu/panda3d/docs/license/ .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. #include "programBase.h"
  19. #include "pnotify.h"
  20. class TestProgram : public ProgramBase {
  21. public:
  22. TestProgram();
  23. bool _bool_a;
  24. int _count_b;
  25. int _int_c;
  26. };
  27. TestProgram::
  28. TestProgram() {
  29. set_program_description
  30. ("This is a simple test program to verify the effectiveness of the "
  31. "ProgramBase base class as a base class for simple programs. It "
  32. "includes some simple options and some description strings that are "
  33. "long enough to require word-wrapping.\r"
  34. "Don't expect anything fancy, though.");
  35. add_runline("[opts]");
  36. add_option
  37. ("bog", "", 90,
  38. "This is test option 'bog'. It is a simple boolean toggle; if it appears "
  39. "at all, it sets a boolean flag to indicate that. If it does not "
  40. "appear, it leaves the boolean flag alone.\r"
  41. "There's not a whole lot of point to this option, when you come down "
  42. "to it.",
  43. &TestProgram::dispatch_none, &_bool_a);
  44. add_option
  45. ("b", "", 90, "Test option b",
  46. &TestProgram::dispatch_count, NULL, &_count_b);
  47. _count_b = 0;
  48. add_option
  49. ("c", "integer_parameter", 90,
  50. "This is test option 'c'. It takes an integer parameter.",
  51. &TestProgram::dispatch_int, NULL, &_int_c);
  52. _int_c = 0;
  53. }
  54. int main(int argc, char *argv[]) {
  55. TestProgram t;
  56. t.parse_command_line(argc, argv);
  57. nout << "Executed successfully.\n"
  58. << " _bool_a = " << t._bool_a << "\n"
  59. << " _count_b = " << t._count_b << "\n"
  60. << " _int_c = " << t._int_c << "\n";
  61. return 0;
  62. }