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