| GL Studio C++ Runtime API

gls_resources.h
Go to the documentation of this file.
1/*! \file
2 \brief disti::GlsResourceFilter classes and methods.
3
4 \par Copyright Information
5
6 Copyright (c) 2017 by The DiSTI Corporation.<br>
7 11301 Corporate Blvd; Suite 100<br>
8 Orlando, Florida 32817<br>
9 USA<br>
10 <br>
11 All rights reserved.<br>
12
13 This Software contains proprietary trade secrets of DiSTI and may not be
14 reproduced, in whole or part, in any form, or by any means of electronic,
15 mechanical, or otherwise, without the written permission of DiSTI. Said
16 permission may be derived through the purchase of applicable DiSTI product
17 licenses which detail the distribution rights of this content and any
18 Derivative Works based on this or other copyrighted DiSTI Software.
19
20 NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
21 AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
22 PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
23 AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
24 IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
25 PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
26
27 LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
28 IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
29 INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
30 DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
31 INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
32 INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBILITY
33 OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
34 EXCEED FIVE DOLLARS (US$5.00).
35
36 The aforementioned terms and restrictions are governed by the laws of the
37 State of Florida and the United States of America.
38
39*/
40
41#ifndef _GLS_RESOURCES_H
42#define _GLS_RESOURCES_H
43
44#include "display_frame.h"
45
46 namespace disti
47{
48/** Used for specifiying a filter for accessing resources
49 */
50 class GlsResourceFilter
51{
52 public:
53 int _levelsUp; ///< Levels of qualification to show in names, -1 is fully qualified.
54 int _groupLevelsDown; ///< How many levels to recurse through groups, -1 is fully recursive.
55 DynamicArray<char*> _excludeList; ///< List of names to exclude from the filter, takes precedence over includes.
56 DynamicArray<char*> _includeList; ///< List of names to include, if empty all names are acceptable.
57 bool _namesOnly; ///< If true, will return names only, and not names and values.
58 DynamicArray<const char*> _parentNameStack; ///< List of parent names, used to append to the name during traversal.
59
60 public:
61 GLS_EXPORT GlsResourceFilter();
62
63 /// Copy constructor
64 /// \param source The object to copy from.
65 GLS_EXPORT GlsResourceFilter( GlsResourceFilter* source );
66
67 /// Copy constructor
68 /// \param source The object to copy from.
69 GLS_EXPORT GlsResourceFilter( GlsResourceFilter& source );
70
71 virtual GLS_EXPORT ~GlsResourceFilter();
72
73 /// How many levels of qualification above the starting point to show in the attribute names.
74 /// This is based on the component heirarchy, not the draw hierarchy.
75 /// For example if you call Altimeter->GetResources() with:
76 /// LevelsUp = 0, expect:
77 /// Altitude: 1000
78 /// LevelsUp = 1, expect:
79 /// Altimeter.Altitude:
80 /// LevelsUp = 2, expect:
81 /// Cockpit.Altimeter.Altitude:
82 /// -1 means full qualification.
83 /// \param value The new qualification level value to set.
84 inline void LevelsUp( int value ) { _levelsUp = value; }
85
86 /// \return Te number of levels of qualification.
87 inline int LevelsUp() { return _levelsUp; }
88
89 /// How many levels of children to show.
90 /// This is different from LevelsUp because this is based on the draw
91 /// heirarchy (Groups rather than components).
92 /// For example with:
93 /// GroupLevelsDown = 0, only the specified object's resources will be shown.
94 /// GroupLevelsDown = 1, only the immeadiate children of the object's resources will be shown.
95 /// GroupLevelsDown = -1, means all children will be shown.
96 /// Note that the name stays fully qualified for the children. For example:
97 /// if GroupLevelsDown == 1 the results would include:
98 /// Altimeter.Visible: 1
99 /// Altimeter.Group1.Visible: 1
100 /// but NOT:
101 /// Altimeter.Group1.Poly.Visible: 1
102 /// \param value The new group traversal level to set.
103 inline void GroupLevelsDown( int value ) { _groupLevelsDown = value; }
104
105 /// \return The number of group levels to traverse.
106 inline int GroupLevelsDown() { return _groupLevelsDown; }
107
108 /// If true, only a list of names will be returned.
109 /// Values will not be returned.
110 /// The format changes to not include the ":".
111 /// \param value The new names only flag to set.
112 inline void NamesOnly( bool value ) { _namesOnly = value; }
113
114 /// \return Whether names only, or names and values will be returned.
115 inline bool NamesOnly() { return _namesOnly; }
116
117 /// Add a resource name to the exclude filter
118 /// Resources on the exclude list will not pass the filter.
119 /// Excludes take precedence over includes.
120 /// \param name The new name to add to the exclude list.
121 void GLS_EXPORT AddExclude( const char* name );
122
123 /// \return The number of exclude entries in the filter.
124 GLS_EXPORT unsigned int ExcludeCount() const;
125
126 /// \return The resource name for the given exclude list entry.
127 /// \param index < ExcludeCount()
128 GLS_EXPORT const char* GetExclude( unsigned int index ) const;
129
130 /// Removes a entry from the exclude list
131 /// This will reduce the ExcludeCount()
132 /// \param index < ExcludeCount()
133 GLS_EXPORT void RemoveExclude( unsigned int index );
134
135 /// Removes all entries from the exclude list
136 GLS_EXPORT void ClearExcludes();
137
138 /// Add a resource name to the include filter
139 /// If there are no includes specified, all resources
140 /// will pass the filter by default.
141 /// If IncludeCount() > 0, then only resources that
142 /// are included will pass the filter.
143 /// \param name The new name to add to the include list.
144 void GLS_EXPORT AddInclude( const char* name );
145
146 /// \return The number of includes in the filter.
147 GLS_EXPORT unsigned int IncludeCount() const;
148
149 /// \return The resource name for the given include list entry.
150 /// \param index < IncludeCount()
151 GLS_EXPORT const char* GetInclude( unsigned int index ) const;
152
153 /// Removes a entry from the include list.
154 /// This will reduce the IncludeCount().
155 /// \param index < IncludeCount()
156 GLS_EXPORT void RemoveInclude( unsigned int index );
157
158 /// Removes all entries from the include list
159 GLS_EXPORT void ClearIncludes();
160
161 /// \return The qualified name for a DisplayFrame.
162 /// \param frame The object to build the name for.
163 /// \param filter The filter currently in use (as this is a static function).
164 static GLS_EXPORT std::string BuildHierarchyName( DisplayFrame* frame, GlsResourceFilter* filter );
165
166 /// \return The qualified name for a DisplayObject.
167 /// \param obj The object to build the name for.
168 /// \param filter The filter currently in use (as this is a static function).
169 static GLS_EXPORT std::string BuildHierarchyName( DisplayObject* obj, GlsResourceFilter* filter );
170
171 /// Test a resource name against the filter.
172 /// \param name The name to test against the filter.
173 /// \return True if the name passes.
174 virtual GLS_EXPORT bool PassFilter( const char* name );
175
176 /// Pushes a parent name onto the filter's parent stack. This is a list of names of objects
177 /// that represents the hierarchy above this object; this should be used by the
178 /// BuildHierarchyName to prepend the parent names when in the editor, as we don't have the
179 /// ComponentBase's Parent frame pointers available.
180 /// \param parent The new parent name to push onto the stack.
181 GLS_EXPORT void PushParentName( const char* parent );
182
183 /// \return The size of the parent name stack.
184 GLS_EXPORT unsigned int ParentNameCount() const;
185
186 /// \return The parent name for the given position on the stack.
187 /// \param index The index of the parent name to return.
188 GLS_EXPORT const char* GetParentName( unsigned int index ) const;
189
190 /// Removes the top entry on the parent name stack.
191 GLS_EXPORT void PopParentName();
192
193 /// Removes all entries on the parent name stack.
194 GLS_EXPORT void ClearParentNames();
195
196 /// Assignment operator
197 /// \param rhs The object to copy from.
198 /// \return The resulting object (this).
199 GLS_EXPORT GlsResourceFilter& operator=( const GlsResourceFilter& rhs );
200};
201
202} // namespace disti
203
204#endif
disti::DisplayFrame
Definition: display_frame.h:87
disti::DisplayObject
Definition: display.h:96
disti::DynamicArray< char * >
disti::GlsResourceFilter
Definition: gls_resources.h:51
disti::GlsResourceFilter::LevelsUp
void LevelsUp(int value)
Definition: gls_resources.h:84
disti::GlsResourceFilter::IncludeCount
unsigned int IncludeCount() const
disti::GlsResourceFilter::PopParentName
void PopParentName()
Removes the top entry on the parent name stack.
disti::GlsResourceFilter::GetInclude
const char * GetInclude(unsigned int index) const
disti::GlsResourceFilter::_groupLevelsDown
int _groupLevelsDown
How many levels to recurse through groups, -1 is fully recursive.
Definition: gls_resources.h:54
disti::GlsResourceFilter::LevelsUp
int LevelsUp()
Definition: gls_resources.h:87
disti::GlsResourceFilter::_excludeList
DynamicArray< char * > _excludeList
List of names to exclude from the filter, takes precedence over includes.
Definition: gls_resources.h:55
disti::GlsResourceFilter::operator=
GlsResourceFilter & operator=(const GlsResourceFilter &rhs)
disti::GlsResourceFilter::ClearParentNames
void ClearParentNames()
Removes all entries on the parent name stack.
disti::GlsResourceFilter::PushParentName
void PushParentName(const char *parent)
disti::GlsResourceFilter::ClearExcludes
void ClearExcludes()
Removes all entries from the exclude list.
disti::GlsResourceFilter::RemoveExclude
void RemoveExclude(unsigned int index)
disti::GlsResourceFilter::ExcludeCount
unsigned int ExcludeCount() const
disti::GlsResourceFilter::GlsResourceFilter
GlsResourceFilter(GlsResourceFilter &source)
disti::GlsResourceFilter::BuildHierarchyName
static std::string BuildHierarchyName(DisplayObject *obj, GlsResourceFilter *filter)
disti::GlsResourceFilter::_includeList
DynamicArray< char * > _includeList
List of names to include, if empty all names are acceptable.
Definition: gls_resources.h:56
disti::GlsResourceFilter::ClearIncludes
void ClearIncludes()
Removes all entries from the include list.
disti::GlsResourceFilter::BuildHierarchyName
static std::string BuildHierarchyName(DisplayFrame *frame, GlsResourceFilter *filter)
disti::GlsResourceFilter::NamesOnly
bool NamesOnly()
Definition: gls_resources.h:115
disti::GlsResourceFilter::GlsResourceFilter
GlsResourceFilter(GlsResourceFilter *source)
disti::GlsResourceFilter::GetExclude
const char * GetExclude(unsigned int index) const
disti::GlsResourceFilter::NamesOnly
void NamesOnly(bool value)
Definition: gls_resources.h:112
disti::GlsResourceFilter::_levelsUp
int _levelsUp
Levels of qualification to show in names, -1 is fully qualified.
Definition: gls_resources.h:53
disti::GlsResourceFilter::_namesOnly
bool _namesOnly
If true, will return names only, and not names and values.
Definition: gls_resources.h:57
disti::GlsResourceFilter::_parentNameStack
DynamicArray< const char * > _parentNameStack
List of parent names, used to append to the name during traversal.
Definition: gls_resources.h:58
disti::GlsResourceFilter::AddInclude
void AddInclude(const char *name)
disti::GlsResourceFilter::ParentNameCount
unsigned int ParentNameCount() const
disti::GlsResourceFilter::PassFilter
virtual bool PassFilter(const char *name)
disti::GlsResourceFilter::GetParentName
const char * GetParentName(unsigned int index) const
disti::GlsResourceFilter::AddExclude
void AddExclude(const char *name)
disti::GlsResourceFilter::RemoveInclude
void RemoveInclude(unsigned int index)
disti::GlsResourceFilter::GroupLevelsDown
void GroupLevelsDown(int value)
Definition: gls_resources.h:103
disti::GlsResourceFilter::GroupLevelsDown
int GroupLevelsDown()
Definition: gls_resources.h:106
display_frame.h
The disti::DisplayFrame class.
GLS_EXPORT
#define GLS_EXPORT
Macro denoting which functions should be visible from the runtime library.
Definition: gls_include.h:52
disti
Definition: bmpimage.h:47