HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OP_StyleManager.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: OP_StyleManager.h ( OP Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __OP_StyleManager__
12 #define __OP_StyleManager__
13 
14 #include "OP_API.h"
15 #include "OP_Output.h"
16 #include "OP_Value.h"
17 #include <DEP/DEP_MicroNode.h>
18 #include <UT/UT_StringMap.h>
19 #include <UT/UT_StringArray.h>
20 #include <UT/UT_UniquePtr.h>
21 #include <iosfwd>
22 
23 class UT_IStream;
24 class OP_Director;
25 
26 #define INVALID_STYLE_VERSION (-1)
27 
29 {
30 public:
32  ~OP_StyleManager();
33 
34  /// For saving to and loading from a hip file.
35  bool save(std::ostream &os, int binary) const;
36  bool load(UT_IStream &is);
37 
38  /// Creation and deletion of styles.
39  bool addStyle(const UT_StringHolder &name,
40  const UT_StringHolder &description,
41  const UT_StringHolder &style);
42  bool renameStyle(const UT_StringHolder &old_name,
43  const UT_StringHolder &new_name);
44  bool reorderStyles(const UT_StringArray &names);
45  void removeStyle(const UT_StringRef &name);
46  void removeAll();
47 
48  /// Fetching information about existing styles.
49  bool hasStyle(const UT_StringRef &name) const;
50  const UT_StringArray &getStyleNames() const;
51  const UT_StringHolder &getStyleDescription(
52  const UT_StringRef &name) const;
53  const UT_StringHolder &getStyleSheet(
54  const UT_StringRef &name) const;
55 
56  /// A simpe way to check for changes in a specific style without using
57  /// micro-nodes for dependency tracking. Good for maintaining a cache.
58  /// Version numbers will be unique for all style sheets within this
59  /// Houdini session.
60  int getStyleVersion(
61  const UT_StringRef &name) const;
62 
63  /// Get the micronode for tracking the set of available styles.
64  /// Propagates dirtiness when a style is added or removed.
65  DEP_MicroNode &getMicroNode();
66  /// Get the micronode for tracking a articular style.
67  /// Propagates dirtiness when the style is changed or removed.
68  DEP_MicroNode *getMicroNode(const UT_StringRef &name);
69 
70  /// Get a reference to the internal style sheet map.
73  { return myStyleSheets; }
74 
75  /// Update references to moved SHOPs (called from
76  /// OP_Node::moveAndUpdateDependencies).
77  void handleOpMoved(const OP_NodeList &src_nodes,
78  const OP_NodeList &dest_nodes);
79 
80 private:
81  static void handleOpChanged(OP_Node *node,
82  OP_EventType reason,
83  void *data,
84  void *cbdata);
85  void handleOpNameChanged(
86  const UT_StringArray &old_names,
87  const UT_StringArray &new_names);
88 
89  UT_StringArray myStyleNames;
90  UT_StringMap<UT_StringHolder> myStyleSheets;
91  UT_StringMap<UT_StringHolder> myStyleDescriptions;
92  UT_StringMap<int> myStyleVersions;
93  UT_StringMap<UT_UniquePtr<DEP_MicroNode> > myStyleMicroNodes;
94  DEP_MicroNode myStyleListMicroNode;
95  OP_Director *myDirector;
96 };
97 
98 #endif
const UT_StringMap< UT_StringHolder > & getStyleSheetMap() const
Get a reference to the internal style sheet map.
const GLuint GLenum const void * binary
Definition: glcorearb.h:1924
GLuint const GLchar * name
Definition: glcorearb.h:786
Create an evaluation context scope with a new node.
Definition: OP_Director.h:67
#define OP_API
Definition: OP_API.h:10
OP_EventType
Definition: OP_Value.h:22
Definition: format.h:895