src1.h 554 B

123456789101112131415161718192021222324252627282930
  1. #ifndef SWIGTOOLDEMO_HPP
  2. #define SWIGTOOLDEMO_HPP
  3. // singleton shared between test app and python
  4. // (Note: this is a demo, remember singletons should not be used)
  5. class TestClass
  6. {
  7. public:
  8. static TestClass* instance()
  9. {
  10. if (_instance == 0)
  11. _instance = new TestClass();
  12. return _instance;
  13. }
  14. void destroy () { delete _instance; _instance = 0; }
  15. protected:
  16. TestClass() {};
  17. ~TestClass(){};
  18. public:
  19. const char* test() { return "Hello World from C++\n"; }
  20. private:
  21. static TestClass* _instance;
  22. };
  23. #endif //SWIGTOOLDEMO_HPP