OSDN Git Service

ref_count.hpp: 2を
authorMyun2 <myun2@nwhite.info>
Mon, 14 May 2012 11:41:37 +0000 (20:41 +0900)
committerMyun2 <myun2@nwhite.info>
Mon, 14 May 2012 11:41:37 +0000 (20:41 +0900)
roast/include/roast/algorithm/ref_count.hpp

index a0ec7c4..9edb5a8 100644 (file)
@@ -14,6 +14,37 @@ namespace roast
        private:
                unsigned int m_count;
        protected:
+               virtual void on_first()=0;
+               virtual void on_last()=0;
+       public:
+               ref_count() : ref_count(0){}
+               
+               void up()
+               {
+                       if ( m_count == 0 ) {
+                               on_first();
+                       }
+                       m_count++;
+               }
+               
+               void down()
+               {
+                       m_count--;
+                       if ( m_count == 0 ) {
+                               on_last();
+                       }
+               }
+               
+               unsigned int get_count(){ return m_count; }
+       };
+       
+       ///////////////////////////////////////////////////////////
+       
+       class ref_count2
+       {
+       private:
+               unsigned int m_count;
+       protected:
                //virtual void on_first()=0;
                //virtual void on_last()=0;
        public: