|
||||
File indexing completed on 2025-01-30 10:03:31
0001 #ifndef ZMUSECOUNT_H 0002 #define ZMUSECOUNT_H 0003 0004 0005 // ---------------------------------------------------------------------- 0006 // 0007 // ZMuseCount.h - utility class for use in reference-counting 0008 // 0009 // 0010 // History: 0011 // 19-Sep-1997 WEB Design stolen, and code adapted, from pp 70-73 of 0012 // Koenig & Moo: "Ruminations on C++" (1996) 0013 // 0014 // ---------------------------------------------------------------------- 0015 0016 0017 class ZMuseCount { 0018 0019 public: 0020 0021 // -------------------------- 0022 // Constructors & destructor: 0023 // -------------------------- 0024 0025 ZMuseCount(); 0026 // Constructor 0027 ZMuseCount( const ZMuseCount & u ); 0028 // Copy constructor 0029 ~ZMuseCount(); 0030 // Destructor 0031 0032 0033 // ----------------------------------- 0034 // Functions useful to a handle class: 0035 // ----------------------------------- 0036 0037 bool only(); 0038 // Is there exactly one copy of the referent? 0039 0040 bool makeonly(); 0041 // Enables the handle (to a ClassType) to refer to a unique (copy of) 0042 // the referent via the following usage: 0043 // if ( u.makeonly() ) /* ZMuseCount u; */ 0044 // p = new ClassType( *p ); /* ClassType * p; */ 0045 // This is useful in implementing copy-on-write semantics 0046 // (i.e., non-shared or value semantics), and would appear just before 0047 // updating (any part of) *p in such a context. 0048 0049 bool reattach( const ZMuseCount & u ); 0050 // Simplifies a handle's implementation of assignment via the following 0051 // usage: 0052 // if ( u.reattach(h.u) ) /* Handle<ClassType> h; */ 0053 // delete p; /* p and u as above */ 0054 // p = h.p; 0055 0056 0057 private: 0058 0059 int * p; 0060 // *p is the reference counter itself 0061 0062 ZMuseCount & operator=( const ZMuseCount & ); 0063 // Forbidden operation on a ZMuseCount object 0064 0065 }; // ZMuseCount 0066 0067 0068 //#include "CLHEP/RefCount/ZMuseCount.icc" 0069 0070 0071 #endif // ZMUSECOUNT_H
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |