root / trunk / libraries / libjni-ecw / include / NCSObject.h @ 12207
History | View | Annotate | Download (3.36 KB)
1 | 3538 | nacho | /********************************************************
|
---|---|---|---|
2 | ** Copyright 2001 Earth Resource Mapping Ltd.
|
||
3 | ** This document contains proprietary source code of
|
||
4 | ** Earth Resource Mapping Ltd, and can only be used under
|
||
5 | ** one of the three licenses as described in the
|
||
6 | ** license.txt file supplied with this distribution.
|
||
7 | ** See separate license.txt file for license details
|
||
8 | ** and conditions.
|
||
9 | **
|
||
10 | ** This software is covered by US patent #6,442,298,
|
||
11 | ** #6,102,897 and #6,633,688. Rights to use these patents
|
||
12 | ** is included in the license agreements.
|
||
13 | **
|
||
14 | ** FILE: $Archive: /NCS/Source/C/NCSServerUtil/NCSObject.h $
|
||
15 | ** CREATED: 3/09/2001 11:46:57 AM
|
||
16 | ** AUTHOR: Simon Cope
|
||
17 | ** PURPOSE: Base CNCSObject header.
|
||
18 | ** EDITS: [xx] ddMmmyy NAME COMMENTS
|
||
19 | *******************************************************/
|
||
20 | |||
21 | #ifndef NCSOBJECT_H
|
||
22 | #define NCSOBJECT_H
|
||
23 | |||
24 | #ifndef NCSTYPES_H
|
||
25 | #include "NCSTypes.h" |
||
26 | #endif // NCSTYPES_H |
||
27 | |||
28 | #ifndef NCSDEFS_H
|
||
29 | #include "NCSDefs.h" |
||
30 | #endif // NCSDEFS_H |
||
31 | |||
32 | #ifndef NCSTIMESTAMP_H
|
||
33 | #include "NCSTimeStamp.h" |
||
34 | #endif // NCSTIMESTAMP_H |
||
35 | |||
36 | /**
|
||
37 | * CNCSObject class. This class tracks the objects creation time, and if logging is set to LOG_LEVEL3
|
||
38 | * then stats about the objects lifetime are logged with a DEBUG build.
|
||
39 | *
|
||
40 | * @author Simon Cope
|
||
41 | * @version $Revision$ $Author$ $Date$
|
||
42 | *
|
||
43 | * @since 2.0
|
||
44 | */
|
||
45 | class NCS_EXPORT CNCSObject { |
||
46 | public:
|
||
47 | class NCS_EXPORT CNCSObjectLife { |
||
48 | public:
|
||
49 | __inline CNCSObjectLife(NCSTimeStampMs &tsLife) { |
||
50 | m_tsCreated = NCSGetTimeStampMs(); |
||
51 | m_ptsLife = &tsLife; |
||
52 | }; |
||
53 | __inline CNCSObjectLife(NCSTimeStampMs *ptsLife = NULL) {
|
||
54 | m_tsCreated = NCSGetTimeStampMs(); |
||
55 | m_ptsLife = ptsLife; |
||
56 | }; |
||
57 | __inline virtual ~CNCSObjectLife() { |
||
58 | if(m_ptsLife) {
|
||
59 | *m_ptsLife += NCSGetTimeStampMs() - m_tsCreated; |
||
60 | } |
||
61 | }; |
||
62 | __inline NCSTimeStampMs CreatedAt(void) {
|
||
63 | return(m_tsCreated);
|
||
64 | }; |
||
65 | __inline NCSTimeStampMs TimeToNow(void) {
|
||
66 | return(NCSGetTimeStampMs() - m_tsCreated);
|
||
67 | }; |
||
68 | protected:
|
||
69 | NCSTimeStampMs m_tsCreated; |
||
70 | NCSTimeStampMs *m_ptsLife; |
||
71 | }; |
||
72 | /**
|
||
73 | * Default Constructor. Writes the current timestamp at construction time to the log file
|
||
74 | * if logging set to LOG_LEVEL3 (DEBUG build only).
|
||
75 | *
|
||
76 | * @see #~CNCSObject()
|
||
77 | */
|
||
78 | CNCSObject(); |
||
79 | /**
|
||
80 | * Destructor. Writes the objects lifetime in ms to the log file if loggin set to LOG_LEVEL3
|
||
81 | * (DEBUG build only).
|
||
82 | *
|
||
83 | * @see #CNCSObject()
|
||
84 | */
|
||
85 | ~CNCSObject(); |
||
86 | |||
87 | /**
|
||
88 | * Get the timestamp for when the objects was constructed.
|
||
89 | *
|
||
90 | * @return NCSTimeStampMs Objects construction timestamp.
|
||
91 | * @see #TimeToNow()
|
||
92 | * @see #~CNCSObject()
|
||
93 | */
|
||
94 | NCSTimeStampMs CreatedAt(void);
|
||
95 | /**
|
||
96 | * Get the objects current lifetime, in ms (ie, current time - construction time in ms).
|
||
97 | *
|
||
98 | * @return NCSTimeStampMs Objects current lifetime in ms.
|
||
99 | * @see #CreatedAt()
|
||
100 | * @see #~CNCSObject()
|
||
101 | */
|
||
102 | NCSTimeStampMs TimeToNow(void);
|
||
103 | |||
104 | private:
|
||
105 | /**
|
||
106 | * ObjectLife object - this does the actual work.
|
||
107 | *
|
||
108 | * @see #CNCSObject()
|
||
109 | * @see #CreatedAt()
|
||
110 | * @see #TimeToNow()
|
||
111 | */
|
||
112 | //CNCSObjectLife *m_pLife;
|
||
113 | // This was changed by Russell.
|
||
114 | // It is only a temp solution but I had a good reason.
|
||
115 | // Ask me before changing back
|
||
116 | |||
117 | /**
|
||
118 | * Time stamp of when the object was constructed.
|
||
119 | *
|
||
120 | * @see #CNCSObject()
|
||
121 | * @see #CreatedAt()
|
||
122 | * @see #TimeToNow()
|
||
123 | */
|
||
124 | NCSTimeStampMs m_tsCreate; |
||
125 | }; |
||
126 | |||
127 | #endif // NCSOBJECT_H |