inlib
1.2.0
|
00001 // Copyright (C) 2010, Guy Barrand. All rights reserved. 00002 // See the file inlib.license for terms. 00003 00004 #ifndef inlib_sg_cbk 00005 #define inlib_sg_cbk 00006 00007 // "cbk" is for callback. 00008 00009 #ifdef INLIB_MEM 00010 #include "../mem" 00011 #endif 00012 00013 #include "../scast" 00014 00015 #include <string> 00016 00017 namespace inlib { 00018 namespace sg { 00019 00020 class cbk { 00021 public: 00022 static const std::string& s_class() { 00023 static const std::string s_v("inlib::sg::cbk"); 00024 return s_v; 00025 } 00026 public: 00027 virtual void* cast(const std::string& a_class) const { 00028 if(void* p = inlib::cmp_cast<cbk>(this,a_class)) {return p;} 00029 return 0; 00030 } 00031 virtual const std::string& s_cls() const {return s_class();} //gui_view rm cam_work. 00032 public: 00033 enum return_action { 00034 return_none, 00035 return_to_render 00036 }; 00037 virtual return_action action() = 0; 00038 virtual cbk* copy() const = 0; 00039 //virtual bool equal(const cbk&) const = 0; //it would need the upper cast. 00040 public: 00041 virtual ~cbk(){ 00042 #ifdef INLIB_MEM 00043 mem::decrement(s_class().c_str()); 00044 #endif 00045 } 00046 protected: 00047 cbk() 00048 :m_single_shoot(false) 00049 { 00050 #ifdef INLIB_MEM 00051 mem::increment(s_class().c_str()); 00052 #endif 00053 } 00054 cbk(const cbk& a_from) 00055 :m_single_shoot(a_from.m_single_shoot) 00056 { 00057 #ifdef INLIB_MEM 00058 mem::increment(s_class().c_str()); 00059 #endif 00060 } 00061 cbk& operator=(const cbk& a_from){ 00062 m_single_shoot = a_from.m_single_shoot; 00063 return *this; 00064 } 00065 public: 00066 void set_single_shoot(bool a_value) {m_single_shoot = a_value;} 00067 bool is_single_shoot() const {return m_single_shoot;} 00068 protected: 00069 bool m_single_shoot; 00070 }; 00071 00072 }} 00073 00074 #endif