github.com/MangoDowner/go-gm@v0.0.0-20180818020936-8baa2bd4408c/misc/swig/callback/callback.h (about) 1 // Copyright 2011 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 class Callback { 6 public: 7 virtual ~Callback() { } 8 virtual std::string run() { return "Callback::run"; } 9 }; 10 11 class Caller { 12 private: 13 Callback *callback_; 14 public: 15 Caller(): callback_(0) { } 16 ~Caller() { delCallback(); } 17 void delCallback() { delete callback_; callback_ = 0; } 18 void setCallback(Callback *cb) { delCallback(); callback_ = cb; } 19 std::string call(); 20 };