HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
STY_Style.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: STY_Style.h ( STY Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __STY_Style__
12 #define __STY_Style__
13 
14 #include "STY_API.h"
15 #include "STY_Types.h"
16 #include "STY_Target.h"
17 #include "STY_SourceLocation.h"
18 #include <UT/UT_NonCopyable.h>
19 #include <UT/UT_IntrusivePtr.h>
20 #include <UT/UT_StringArray.h>
21 
22 class STY_LoadContext;
23 class STY_Results;
24 class STY_ResultsFilter;
25 class UT_JSONValueMap;
26 
27 /// Represents a style sheet entry that contains a target and overrides.
29  public UT_NonCopyable,
30  public UT_IntrusiveRefCounter<STY_Style>
31 {
32 public:
33  STY_Style(const UT_JSONValue *json,
34  const STY_LoadContext *load_context,
35  STY_StyleSheetLoadMode load_mode,
36  const char* file_name);
38  const STY_TargetHandle &target,
39  const UT_StringArray &import_overrides,
40  const STY_OverrideBlockHandle &local_overrides,
42  STY_Style(const STY_Style &src,
43  const STY_OverrideBlockHandle &local_overrides);
44  ~STY_Style();
45 
46  /// Returns the label given to this style entry.
47  const UT_StringHolder &getLabel() const
48  { return myLabel; }
49 
50  /// Returns the node path for this style entry
51  const UT_StringHolder &getPath() const
52  { return myPath; }
53 
54  /// Returns the target the style sheet entry is intended for.
55  const STY_TargetHandle &getTarget() const
56  { return myTargetHandle; }
57 
58  /// Returns the overrides referenced by the style sheet entry, and any
59  /// defined within the style entry (in the map with an empty string key).
61  { return myOverrideSets; }
62  /// Return the names of referenced overrides in the order specified in
63  /// the JSON array. This will include the names of sets that could not
64  /// actually be found in the load context.
66  { return myOverrideSetsNames; }
67 
68  /// Obtains the list of data names that the entry's override scripts
69  /// are interested in for their input argument binding.
70  const UT_StringArray &getOverrideBindingDataNames() const;
71 
72  /// Gets the flags for this style entry.
74  { return myFlags; }
75 
77  { return mySourceLocation; }
78 
79  /// Create a JSON map for saving to a style sheet. Not reference counted.
80  void saveStyleSheets(UT_JSONValue *values,
82  const exint num_values,
83  const STY_TargetHandle &target,
84  bool evaluate_scripts_if_possible,
85  bool save_verbose,
86  bool save_path) const;
87 
88  /// Calculate override values from this style for an array of closures.
89  void getResults(STY_Results **results,
91  bool all_closures_identical,
92  const exint num_values,
93  const STY_ResultsFilter &filter) const;
94 
95  /// Gather just the categories and names of the overrides that would
96  /// be set by this style if it were to match.
97  void getOverrideNames(STY_OverrideNames &override_names) const;
98 
99  /// Returns a style entry identical to this one but without any overrides
100  /// that match the passed in overrides parameter. Returns nullptr if there
101  /// are no overrides left after removing these. Returns this if no
102  /// overrides are removed.
103  const STY_Style *cloneWithOverridesRemoved(
104  const STY_OverrideNames &override_names) const;
105 
106 private:
107  void loadStyle(const UT_JSONValue *json,
108  const STY_LoadContext *load_context,
109  STY_StyleSheetLoadMode load_mode);
110  void buildOverrideBindingDataNames();
111 
112  UT_StringHolder myLabel;
113  UT_StringHolder myPath;
114  STY_TargetHandle myTargetHandle;
115  STY_OverrideBlockMap myOverrideSets;
116  UT_StringArray myOverrideSetsNames;
117  UT_StringArray myOverrideBindingDataNames;
118  STY_StyleFlags myFlags;
119  STY_SourceLocation mySourceLocation;
120 };
121 
122 #endif
123 
const UT_StringHolder & getPath() const
Returns the node path for this style entry.
Definition: STY_Style.h:51
const UT_StringArray & getOverrideSetsNames() const
Definition: STY_Style.h:65
const STY_TargetHandle & getTarget() const
Returns the target the style sheet entry is intended for.
Definition: STY_Style.h:55
UT_JSONValueMap stores a map/dictionary of UT_JSONValue objects.
GLuint GLsizei const GLchar * label
Definition: glcorearb.h:2544
STY_StyleSheetLoadMode
Definition: STY_Types.h:63
GLbitfield flags
Definition: glcorearb.h:1595
Represents a style sheet entry that contains a target and overrides.
Definition: STY_Style.h:28
#define STY_API
Definition: STY_API.h:10
A reference counter base class for use with UT_IntrusivePtr.
int64 exint
Definition: SYS_Types.h:115
GLenum target
Definition: glcorearb.h:1666
GLenum GLsizei GLsizei GLint * values
Definition: glcorearb.h:1601
const STY_OverrideBlockMap & getOverrideSets() const
Definition: STY_Style.h:60
Fully describes a stye sheet source location.
Class to store JSON objects as C++ objects.
Definition: UT_JSONValue.h:75
STY_SourceLocation getSourceLocation() const
Definition: STY_Style.h:76
STY_StyleFlags
Flags that may be set on styles.
Definition: STY_Types.h:78
const UT_StringHolder & getLabel() const
Returns the label given to this style entry.
Definition: STY_Style.h:47
STY_StyleFlags getFlags() const
Gets the flags for this style entry.
Definition: STY_Style.h:73
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glcorearb.h:1296
GLenum src
Definition: glcorearb.h:1792