SHOGUN
v3.2.0
|
00001 /* 00002 * This program is free software; you can redistribute it and/or modify 00003 * it under the terms of the GNU General Public License as published by 00004 * the Free Software Foundation; either version 3 of the License, or 00005 * (at your option) any later version. 00006 * 00007 * Copyright (C) 2012 Soeren Sonnenburg 00008 */ 00009 #ifndef __SGREFERENCED_DATA_H__ 00010 #define __SGREFERENCED_DATA_H__ 00011 00012 #include <shogun/lib/common.h> 00013 00014 namespace shogun 00015 { 00016 class RefCount; 00017 00019 class SGReferencedData 00020 { 00021 public: 00023 SGReferencedData(bool ref_counting=true); 00024 00026 SGReferencedData(const SGReferencedData &orig); 00027 00029 SGReferencedData& operator= (const SGReferencedData &orig); 00030 00036 virtual ~SGReferencedData(); 00037 00042 int32_t ref_count(); 00043 00044 protected: 00046 void copy_refcount(const SGReferencedData &orig); 00047 00052 int32_t ref(); 00053 00059 int32_t unref(); 00060 00062 virtual void copy_data(const SGReferencedData &orig)=0; 00063 00065 virtual void init_data()=0; 00066 00068 virtual void free_data()=0; 00069 00070 private: 00071 00073 RefCount* m_refcount; 00074 }; 00075 } 00076 #endif // __SGREFERENCED_DATA_H__