Statistics
| Revision:

root / trunk / libraries / libjni-ecwcompress / include / NCSObject.h @ 13136

History | View | Annotate | Download (3.11 KB)

1
/********************************************************
2
** Copyright 2001 Earth Resource Mapping Pty Ltd.
3
** This document contains unpublished source code of
4
** Earth Resource Mapping Pty Ltd. This notice does
5
** not indicate any intention to publish the source
6
** code contained herein.
7
**
8
** FILE:     $Archive: /NCS/Source/C/NCSServerUtil/NCSObject.h $
9
** CREATED:  3/09/2001 11:46:57 AM
10
** AUTHOR:   Simon Cope
11
** PURPOSE:  Base CNCSObject header.
12
** EDITS:    [xx] ddMmmyy NAME COMMENTS
13
 *******************************************************/
14

    
15
#ifndef NCSOBJECT_H
16
#define NCSOBJECT_H
17

    
18
#ifndef NCSTYPES_H
19
#include "NCSTypes.h"
20
#endif // NCSTYPES_H
21

    
22
#ifndef NCSDEFS_H
23
#include "NCSDefs.h"
24
#endif // NCSDEFS_H
25

    
26
#ifndef NCSTIMESTAMP_H
27
#include "NCSTimeStamp.h"
28
#endif // NCSTIMESTAMP_H
29

    
30
/**
31
 * CNCSObject class.  This class tracks the objects creation time, and if logging is set to LOG_LEVEL3
32
 * then stats about the objects lifetime are logged with a DEBUG build.
33
 * 
34
 * @author       Simon Cope
35
 * @version      $Revision: 3538 $ $Author: nacho $ $Date: 2006-01-09 12:56:54 +0100 (Mon, 09 Jan 2006) $ 
36
 *               
37
 * @since        2.0
38
 */
39
class NCS_EXPORT CNCSObject {
40
public:
41
        class NCS_EXPORT CNCSObjectLife {
42
        public:
43
                __inline CNCSObjectLife(NCSTimeStampMs &tsLife) {
44
                        m_tsCreated = NCSGetTimeStampMs();
45
                        m_ptsLife = &tsLife;
46
                };
47
                __inline CNCSObjectLife(NCSTimeStampMs *ptsLife = NULL) {
48
                        m_tsCreated = NCSGetTimeStampMs();
49
                        m_ptsLife = ptsLife;
50
                };
51
                __inline virtual ~CNCSObjectLife() {
52
                        if(m_ptsLife) {
53
                                *m_ptsLife += NCSGetTimeStampMs() - m_tsCreated;
54
                        }
55
                };
56
                __inline NCSTimeStampMs CreatedAt(void) {
57
                        return(m_tsCreated);
58
                };
59
                __inline NCSTimeStampMs TimeToNow(void) {
60
                        return(NCSGetTimeStampMs() - m_tsCreated);
61
                };
62
        protected:
63
                NCSTimeStampMs m_tsCreated;
64
                NCSTimeStampMs *m_ptsLife;
65
        };
66
        /**
67
         * Default Constructor.  Writes the current timestamp at construction time to the log file
68
         * if logging set to LOG_LEVEL3 (DEBUG build only).
69
         * 
70
         * @see          #~CNCSObject()
71
         */
72
        CNCSObject();
73
        /**
74
         * Destructor.  Writes the objects lifetime in ms to the log file if loggin set to LOG_LEVEL3
75
         * (DEBUG build only).
76
         * 
77
         * @see          #CNCSObject()
78
         */
79
        ~CNCSObject();
80

    
81
        /**
82
         * Get the timestamp for when the objects was constructed.
83
         * 
84
         * @return       NCSTimeStampMs                Objects construction timestamp.
85
         * @see          #TimeToNow()
86
         * @see                         #~CNCSObject()
87
         */
88
        NCSTimeStampMs CreatedAt(void);
89
        /**
90
         * Get the objects current lifetime, in ms (ie, current time - construction time in ms).
91
         * 
92
         * @return       NCSTimeStampMs                Objects current lifetime in ms.
93
         * @see          #CreatedAt()
94
         * @see                         #~CNCSObject()
95
         */
96
        NCSTimeStampMs TimeToNow(void);
97

    
98
private:
99
        /**
100
         * ObjectLife object - this does the actual work.
101
         * 
102
         * @see          #CNCSObject()
103
         * @see                         #CreatedAt()
104
         * @see                         #TimeToNow()
105
         */
106
        //CNCSObjectLife                *m_pLife; 
107
        // This was changed by Russell.
108
        // It is only a temp solution but I had a good reason.
109
        // Ask me before changing back
110

    
111
        /**
112
         * Time stamp of when the object was constructed.
113
         * 
114
         * @see          #CNCSObject()
115
         * @see                         #CreatedAt()
116
         * @see                         #TimeToNow()
117
         */
118
        NCSTimeStampMs m_tsCreate;
119
};
120

    
121
#endif // NCSOBJECT_H
122