source: trunk/IPs/systemC/processor/Morpheo/Behavioural/include/ClassicReferenceCounter.h @ 88

Last change on this file since 88 was 88, checked in by rosiere, 15 years ago

Almost complete design
with Test and test platform

  • Property svn:keywords set to Id
File size: 1.4 KB
Line 
1#ifndef _CLASSIC_REF_COUNTER_
2#define _CLASSIC_REF_COUNTER_
3
4#include "Behavioural/include/IReferenceCounters.h"
5#include <cassert>
6
7namespace morpheo {
8        namespace ReferenceCountersUtils {
9       
10        //*****************************************Class declaration*****************************************//
11       
12        class ClassicReferenceCounter : virtual public IReferenceCounter<unsigned long> {
13        private:
14                unsigned long m_ulReferenceCounter; 
15        protected:
16                inline explicit ClassicReferenceCounter(void); 
17                inline ~ClassicReferenceCounter(void); 
18        public: 
19                inline unsigned long getReferenceCount(void) const;
20               
21                inline unsigned long attach(void); 
22               
23                inline unsigned long detach(void); 
24        };     
25
26        //**********************************Inline definition************************************************//
27       
28        ClassicReferenceCounter::ClassicReferenceCounter(void) : m_ulReferenceCounter(1) {}
29
30        ClassicReferenceCounter::~ClassicReferenceCounter(void) { 
31                assert( m_ulReferenceCounter == 0 || m_ulReferenceCounter == 1 );
32        }
33       
34        unsigned long ClassicReferenceCounter::attach(void) {
35                return ++m_ulReferenceCounter; 
36        }
37       
38        unsigned long ClassicReferenceCounter::detach(void) {
39                return --m_ulReferenceCounter ? m_ulReferenceCounter : (delete this , 0 ) ; 
40        }
41
42       
43        unsigned long ClassicReferenceCounter::getReferenceCount(void) const {
44                return m_ulReferenceCounter;
45        }
46
47        } //end of namespace ReferenceCountersUtils.
48}// end of namespace morpheo.
49
50#endif // _CLASSIC_REF_COUNTER_
51 
Note: See TracBrowser for help on using the repository browser.