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  */
51 {
52 public:
53  int _levelsUp;
54  int _groupLevelsDown;
55  DynamicArray<char*, true> _excludeList;
56  DynamicArray<char*, true> _includeList;
57  bool _namesOnly;
58  DynamicArray<const char*, true> _parentNameStack;
59 
60 public:
61  GLS_EXPORT GlsResourceFilter();
62  /// Copy constructor
63  GLS_EXPORT GlsResourceFilter( GlsResourceFilter* source );
64  GLS_EXPORT GlsResourceFilter( GlsResourceFilter& source );
65 
66  virtual GLS_EXPORT ~GlsResourceFilter();
67 
68  /** How many levels of qualification above the starting point to show in the attribute names.
69  * This is based on the component heirarchy, not the draw hierarchy.
70  * For example if you call Altimeter->GetResources() with:
71  * LevelsUp = 0, expect:
72  * Altitude: 1000
73  * LevelsUp = 1, expect:
74  * Altimeter.Altitude:
75  * LevelsUp = 2, expect:
76  * Cockpit.Altimeter.Altitude:
77  * -1 means full qualification.
78  */
79  inline int LevelsUp() { return _levelsUp; }
80  inline void LevelsUp( int value ) { _levelsUp = value; }
81 
82  /** How many levels of children to show.
83  * This is different from LevelsUp because this is based on the draw
84  * heirarchy (Groups rather than components).
85  * For example with:
86  * GroupLevelsDown = 0, only the specified object's resources will be shown.
87  * GroupLevelsDown = 1, only the immeadiate children of the object's resources will be shown.
88  * GroupLevelsDown = -1, means all children will be shown.
89  * Note that the name stays fully qualified for the children. For example:
90  * if GroupLevelsDown == 1 the results would include:
91  * Altimeter.Visible: 1
92  * Altimeter.Group1.Visible: 1
93  * but NOT:
94  * Altimeter.Group1.Poly.Visible: 1
95  */
96  inline int GroupLevelsDown() { return _groupLevelsDown; }
97  inline void GroupLevelsDown( int value ) { _groupLevelsDown = value; }
98 
99  /** If true, only a list of names will be returned.
100  * Values will not be returned.
101  * The format changes to not include the ":".
102  */
103  inline bool NamesOnly() { return _namesOnly; }
104  inline void NamesOnly( bool value ) { _namesOnly = value; }
105 
106  /** Add a resource name to the exclude filter
107  * Resources on the exclude list will not pass the filter.
108  * Excludes take precedence over includes
109  */
110  void GLS_EXPORT AddExclude( const char* name );
111 
112  /// Returns the number of exclude entries in the filter
113  GLS_EXPORT unsigned int ExcludeCount() const;
114 
115  /** Returns the resource name for the given exclude list entry
116  * \param index < ExcludeCount()
117  */
118  GLS_EXPORT const char* GetExclude( unsigned int index ) const;
119 
120  /** Removes a entry from the exclude list
121  * This will reduce the ExcludeCount()
122  * \param index < ExcludeCount()
123  */
124  GLS_EXPORT void RemoveExclude( unsigned int index );
125 
126  /// Removes all entries from the exclude list
127  GLS_EXPORT void ClearExcludes();
128 
129  /** Add a resource name to the include filter
130  * If there are no includes specified, all resources
131  * will pass the filter by default.
132  * If IncludeCount() > 0, then only resources that
133  * are included will pass the filter.
134  */
135  void GLS_EXPORT AddInclude( const char* name );
136 
137  /// Returns the number of includes in the filter
138  GLS_EXPORT unsigned int IncludeCount() const;
139 
140  /** Returns the resource name for the given include list entry
141  * \param index < IncludeCount()
142  */
143  GLS_EXPORT const char* GetInclude( unsigned int index ) const;
144 
145  /** Removes a entry from the include list
146  * This will reduce the IncludeCount()
147  * \param index < IncludeCount()
148  */
149  GLS_EXPORT void RemoveInclude( unsigned int index );
150 
151  /// Removes all entries from the include list
152  GLS_EXPORT void ClearIncludes();
153 
154  /// \returns the qualified name for a DisplayFrame.
155  static GLS_EXPORT std::string BuildHierarchyName( DisplayFrame* frame, GlsResourceFilter* filter );
156  /// \returns the qualified name for a DisplayObject.
157  static GLS_EXPORT std::string BuildHierarchyName( DisplayObject* obj, GlsResourceFilter* filter );
158 
159  /// Test a resource name against the filter
160  virtual GLS_EXPORT bool PassFilter( const char* name );
161 
162  /** Pushes a parent name onto the filter's parent stack. This is a list of names of objects
163  * that represents the hierarchy above this object; this should be used by the
164  * BuildHierarchyName to prepend the parent names when in the editor, as we don't have the
165  * ComponentBase's Parent frame pointers available.
166  */
167  GLS_EXPORT void PushParentName( const char* parent );
168 
169  /** Returns the size of the parent name stack */
170  GLS_EXPORT unsigned int ParentNameCount() const;
171 
172  /** Returns the parent name for the given position on the stack */
173  GLS_EXPORT const char* GetParentName( unsigned int index ) const;
174 
175  /** Removes the top entry on the parent name stack */
176  GLS_EXPORT void PopParentName();
177 
178  /** Removes all entries on the parent name stack */
179  GLS_EXPORT void ClearParentNames();
180 
181  /// assignment operator
182  GLS_EXPORT GlsResourceFilter& operator=( const GlsResourceFilter& rhs );
183 };
184 
185 } // namespace disti
186 
187 #endif
const char * GetParentName(unsigned int index) const
void ClearExcludes()
Removes all entries from the exclude list.
const char * GetInclude(unsigned int index) const
unsigned int ExcludeCount() const
Returns the number of exclude entries in the filter.
bool NamesOnly()
Definition: gls_resources.h:103
unsigned int ParentNameCount() const
void RemoveInclude(unsigned int index)
GlsResourceFilter & operator=(const GlsResourceFilter &rhs)
assignment operator
void AddInclude(const char *name)
static std::string BuildHierarchyName(DisplayFrame *frame, GlsResourceFilter *filter)
virtual bool PassFilter(const char *name)
Test a resource name against the filter.
unsigned int IncludeCount() const
Returns the number of includes in the filter.
void AddExclude(const char *name)
void ClearIncludes()
Removes all entries from the include list.
int LevelsUp()
Definition: gls_resources.h:79
int GroupLevelsDown()
Definition: gls_resources.h:96
The disti::DisplayFrame class.
void RemoveExclude(unsigned int index)
Definition: gls_resources.h:50
const char * GetExclude(unsigned int index) const
Definition: bmpimage.h:46
void PushParentName(const char *parent)