Coin  4.0.3
Coin3D core library
Loading...
Searching...
No Matches
SbProfilingData.h
1#ifndef COIN_SBPROFILINGDATA_H
2#define COIN_SBPROFILINGDATA_H
3
4/**************************************************************************\
5 * Copyright (c) Kongsberg Oil & Gas Technologies AS
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
10 * met:
11 *
12 * Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
14 *
15 * Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * Neither the name of the copyright holder nor the names of its
20 * contributors may be used to endorse or promote products derived from
21 * this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34\**************************************************************************/
35
36#include <Inventor/SbBasic.h>
37#include <Inventor/SbTime.h>
38#include <Inventor/SoType.h>
39#include <Inventor/SbName.h>
40#include <Inventor/lists/SbList.h>
41#include <Inventor/tools/SbPimplPtr.h>
42
43class SoNode;
44class SoPath;
45class SoFullPath;
46class SbProfilingDataP;
47
48typedef void * SbProfilingNodeKey; // void since it should not be dereferenced
49typedef int16_t SbProfilingNodeTypeKey;
50typedef const char * SbProfilingNodeNameKey;
51
52class COIN_DLL_API SbProfilingData {
53public:
54 SbProfilingData(void);
56 ~SbProfilingData(void);
57
58 void setActionType(SoType actiontype);
59 SoType getActionType(void) const;
60
61 void setActionStartTime(SbTime starttime);
62 SbTime getActionStartTime(void) const;
63 void setActionStopTime(SbTime stoptime);
64 SbTime getActionStopTime(void) const;
65 SbTime getActionDuration(void) const;
66
67 // profiling setters
68 enum FootprintType {
69 MEMORY_SIZE,
70 VIDEO_MEMORY_SIZE
71 };
72
73 enum NodeFlag {
74 GL_CACHED_FLAG,
75 CULLED_FLAG
76 };
77
78 enum NodeDataQueryFlags {
79 INCLUDE_CHILDREN = 0x01
80 };
81
82 void setNodeTiming(const SoPath * path, SbTime timing);
83 void setNodeTiming(int idx, SbTime timing);
84 void preOffsetNodeTiming(int idx, SbTime timing);
85 SbTime getNodeTiming(const SoPath * path, unsigned int queryflags = 0) const;
86 SbTime getNodeTiming(int idx, unsigned int queryflags = 0) const;
87
88 void setNodeFootprint(const SoPath * path, FootprintType type,
89 size_t footprint);
90 void setNodeFootprint(int idx, FootprintType type, size_t footprint);
91 size_t getNodeFootprint(const SoPath * path, FootprintType type,
92 unsigned int queryflags = 0) const;
93 size_t getNodeFootprint(int idx, FootprintType type,
94 unsigned int queryflags = 0) const;
95
96 void setNodeFlag(const SoPath * path, NodeFlag flag, SbBool on);
97 void setNodeFlag(int idx, NodeFlag flag, SbBool on);
98 SbBool getNodeFlag(const SoPath * path, NodeFlag flag) const;
99 SbBool getNodeFlag(int idx, NodeFlag flag) const;
100
101 int getIndex(const SoPath * path, SbBool create = FALSE);
102 int getParentIndex(int idx) const;
103
104 SoType getNodeType(int idx) const;
105 SbName getNodeName(int idx) const;
106
107 int getLongestNameLength(void) const;
108 int getLongestTypeNameLength(void) const;
109
110 int getNumNodeEntries(void) const;
111
112 typedef void SbProfilingDataCB(void * userdata, const SbProfilingData & data, const SbList<SoNode *> & pointers, SbList<int> & childindices, int idx);
113 void reportAll(SbProfilingDataCB * callback, void * userdata) const;
114
115 // read out pre-categorized data
116 void getStatsForTypesKeyList(SbList<SbProfilingNodeTypeKey> & keys_out) const;
117 void getStatsForType(SbProfilingNodeTypeKey type,
118 SbTime & total, SbTime & max, uint32_t & count) const;
119
120 void getStatsForNamesKeyList(SbList<SbProfilingNodeNameKey> & keys_out) const;
121 void getStatsForName(SbProfilingNodeNameKey name,
122 SbTime & total, SbTime & max, uint32_t & count) const;
123
124 // statistics management
125 void reset(void);
126
127 SbProfilingData & operator = (const SbProfilingData & rhs);
128 SbProfilingData & operator += (const SbProfilingData & rhs);
129
130 int operator == (const SbProfilingData & rhs) const;
131 int operator != (const SbProfilingData & rhs) const;
132
133
134 // debug - return profiling data overhead
135 size_t getProfilingDataSize(void) const;
136
137protected:
138 SoType actionType;
139 SbTime actionStartTime;
140 SbTime actionStopTime;
141
142private:
144
145 void constructorInit(void);
146
147 SbBool isPathMatch(const SoFullPath * path, int pathlen, int idx);
148
149 int getIndexCreate(const SoFullPath * path, int pathlen);
150 int getIndexNoCreate(const SoPath * path, int pathlen) const;
151 int getIndexForwardCreate(const SoFullPath * path, int pathlen,
152 int parentindex);
153 int getIndexForwardNoCreate(const SoFullPath * path, int pathlen,
154 int parentindex) const;
155
156}; // SbProfilingData
157
158#endif // !COIN_SBPROFILINGDATA_H
The SbList class is a template container class for lists.
Definition SbList.h:70
The SbName class stores strings by reference.
Definition SbName.h:40
Definition SbPimplPtr.h:55
Data structure for gathering scene graph traversal profiling information.
Definition SbProfilingData.h:52
The SbTime class instances represents time values.
Definition SbTime.h:50
The SoFullPath class allows examination of hidden children in paths.
Definition SoFullPath.h:38
The SoNode class is the base class for nodes used in scene graphs.
Definition SoNode.h:56
The SoPath class is a container class for traversal path descriptions.
Definition SoPath.h:52
The SoType class is the basis for the runtime type system in Coin.
Definition SoType.h:59