GL Studio C++ Runtime API
gls_resources.h
Go to the documentation of this file.
1/// \file gls_resources.h
2/// \brief disti::GlsResourceFilter classes and methods.
3///
4/// \par Copyright Information
5///
6/// Copyright (c) 2017 by The DiSTI Corporation.<br>
7/// 12249 Science Drive; Suite 300<br>
8/// Orlando, Florida 32826<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#ifndef DISTI_INCLUDED_GLS_RESOURCES_H
40#define DISTI_INCLUDED_GLS_RESOURCES_H
41
42#include "display_frame.h"
43
44namespace disti
45{
46/** Used for specifiying a filter for accessing resources
47 */
49{
50public:
51 int _levelsUp; ///< Levels of qualification to show in names, -1 is fully qualified.
52 int _groupLevelsDown; ///< How many levels to recurse through groups, -1 is fully recursive.
53 DynamicArray<char*> _excludeList; ///< List of names to exclude from the filter, takes precedence over includes.
54 DynamicArray<char*> _includeList; ///< List of names to include, if empty all names are acceptable.
55 bool _namesOnly; ///< If true, will return names only, and not names and values.
56 DynamicArray<const char*> _parentNameStack; ///< List of parent names, used to append to the name during traversal.
57
58public:
60
61 /// Copy constructor
62 /// \param source The object to copy from.
64
65 /// Copy constructor
66 /// \param source The object to copy from.
68
70
71 /// How many levels of qualification above the starting point to show in the attribute names.
72 /// This is based on the component heirarchy, not the draw hierarchy.
73 /// For example if you call Altimeter->GetResources() with:
74 /// LevelsUp = 0, expect:
75 /// Altitude: 1000
76 /// LevelsUp = 1, expect:
77 /// Altimeter.Altitude:
78 /// LevelsUp = 2, expect:
79 /// Cockpit.Altimeter.Altitude:
80 /// -1 means full qualification.
81 /// \param value The new qualification level value to set.
82 void LevelsUp( int value ) { _levelsUp = value; }
83
84 /// \return Te number of levels of qualification.
85 int LevelsUp() { return _levelsUp; }
86
87 /// How many levels of children to show.
88 /// This is different from LevelsUp because this is based on the draw
89 /// heirarchy (Groups rather than components).
90 /// For example with:
91 /// GroupLevelsDown = 0, only the specified object's resources will be shown.
92 /// GroupLevelsDown = 1, only the immeadiate children of the object's resources will be shown.
93 /// GroupLevelsDown = -1, means all children will be shown.
94 /// Note that the name stays fully qualified for the children. For example:
95 /// if GroupLevelsDown == 1 the results would include:
96 /// Altimeter.Visible: 1
97 /// Altimeter.Group1.Visible: 1
98 /// but NOT:
99 /// Altimeter.Group1.Poly.Visible: 1
100 /// \param value The new group traversal level to set.
101 void GroupLevelsDown( int value ) { _groupLevelsDown = value; }
102
103 /// \return The number of group levels to traverse.
105
106 /// If true, only a list of names will be returned.
107 /// Values will not be returned.
108 /// The format changes to not include the ":".
109 /// \param value The new names only flag to set.
110 void NamesOnly( bool value ) { _namesOnly = value; }
111
112 /// \return Whether names only, or names and values will be returned.
113 bool NamesOnly() { return _namesOnly; }
114
115 /// Add a resource name to the exclude filter
116 /// Resources on the exclude list will not pass the filter.
117 /// Excludes take precedence over includes.
118 /// \param name The new name to add to the exclude list.
119 void GLS_EXPORT AddExclude( const char* name );
120
121 /// \return The number of exclude entries in the filter.
122 GLS_EXPORT unsigned int ExcludeCount() const;
123
124 /// \return The resource name for the given exclude list entry.
125 /// \param index < ExcludeCount()
126 GLS_EXPORT const char* GetExclude( unsigned int index ) const;
127
128 /// Removes a entry from the exclude list
129 /// This will reduce the ExcludeCount()
130 /// \param index < ExcludeCount()
131 GLS_EXPORT void RemoveExclude( unsigned int index );
132
133 /// Removes all entries from the exclude list
135
136 /// Add a resource name to the include filter
137 /// If there are no includes specified, all resources
138 /// will pass the filter by default.
139 /// If IncludeCount() > 0, then only resources that
140 /// are included will pass the filter.
141 /// \param name The new name to add to the include list.
142 void GLS_EXPORT AddInclude( const char* name );
143
144 /// \return The number of includes in the filter.
145 GLS_EXPORT unsigned int IncludeCount() const;
146
147 /// \return The resource name for the given include list entry.
148 /// \param index < IncludeCount()
149 GLS_EXPORT const char* GetInclude( unsigned int index ) const;
150
151 /// Removes a entry from the include list.
152 /// This will reduce the IncludeCount().
153 /// \param index < IncludeCount()
154 GLS_EXPORT void RemoveInclude( unsigned int index );
155
156 /// Removes all entries from the include list
158
159 /// \return The qualified name for a DisplayFrame.
160 /// \param frame The object to build the name for.
161 /// \param filter The filter currently in use (as this is a static function).
162 static GLS_EXPORT std::string BuildHierarchyName( DisplayFrame* frame, GlsResourceFilter* filter );
163
164 /// \return The qualified name for a DisplayObject.
165 /// \param obj The object to build the name for.
166 /// \param filter The filter currently in use (as this is a static function).
168
169 /// Test a resource name against the filter.
170 /// \param name The name to test against the filter.
171 /// \return True if the name passes.
172 virtual GLS_EXPORT bool PassFilter( const char* name );
173
174 /// Pushes a parent name onto the filter's parent stack. This is a list of names of objects
175 /// that represents the hierarchy above this object; this should be used by the
176 /// BuildHierarchyName to prepend the parent names when in the editor, as we don't have the
177 /// ComponentBase's Parent frame pointers available.
178 /// \param parent The new parent name to push onto the stack.
179 GLS_EXPORT void PushParentName( const char* parent );
180
181 /// \return The size of the parent name stack.
182 GLS_EXPORT unsigned int ParentNameCount() const;
183
184 /// \return The parent name for the given position on the stack.
185 /// \param index The index of the parent name to return.
186 GLS_EXPORT const char* GetParentName( unsigned int index ) const;
187
188 /// Removes the top entry on the parent name stack.
190
191 /// Removes all entries on the parent name stack.
193
194 /// Assignment operator
195 /// \param rhs The object to copy from.
196 /// \return The resulting object (this).
198};
199
200} // namespace disti
201
202#endif
Definition: display_frame.h:86
Definition: display.h:95
Definition: gls_resources.h:49
void LevelsUp(int value)
Definition: gls_resources.h:82
unsigned int IncludeCount() const
void PopParentName()
Removes the top entry on the parent name stack.
const char * GetInclude(unsigned int index) const
int _groupLevelsDown
How many levels to recurse through groups, -1 is fully recursive.
Definition: gls_resources.h:52
int LevelsUp()
Definition: gls_resources.h:85
DynamicArray< char * > _excludeList
List of names to exclude from the filter, takes precedence over includes.
Definition: gls_resources.h:53
GlsResourceFilter & operator=(const GlsResourceFilter &rhs)
void ClearParentNames()
Removes all entries on the parent name stack.
void PushParentName(const char *parent)
void ClearExcludes()
Removes all entries from the exclude list.
void RemoveExclude(unsigned int index)
unsigned int ExcludeCount() const
GlsResourceFilter(GlsResourceFilter &source)
static std::string BuildHierarchyName(DisplayObject *obj, GlsResourceFilter *filter)
DynamicArray< char * > _includeList
List of names to include, if empty all names are acceptable.
Definition: gls_resources.h:54
void ClearIncludes()
Removes all entries from the include list.
static std::string BuildHierarchyName(DisplayFrame *frame, GlsResourceFilter *filter)
bool NamesOnly()
Definition: gls_resources.h:113
GlsResourceFilter(GlsResourceFilter *source)
const char * GetExclude(unsigned int index) const
void NamesOnly(bool value)
Definition: gls_resources.h:110
int _levelsUp
Levels of qualification to show in names, -1 is fully qualified.
Definition: gls_resources.h:51
bool _namesOnly
If true, will return names only, and not names and values.
Definition: gls_resources.h:55
DynamicArray< const char * > _parentNameStack
List of parent names, used to append to the name during traversal.
Definition: gls_resources.h:56
void AddInclude(const char *name)
unsigned int ParentNameCount() const
virtual bool PassFilter(const char *name)
const char * GetParentName(unsigned int index) const
void AddExclude(const char *name)
void RemoveInclude(unsigned int index)
void GroupLevelsDown(int value)
Definition: gls_resources.h:101
int GroupLevelsDown()
Definition: gls_resources.h:104
The disti::DisplayFrame class.
#define GLS_EXPORT
Macro denoting which functions should be visible from the runtime library.
Definition: gls_include.h:50
Definition: bmpimage.h:46