HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OP_OpNamespaceHierarchy.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_OpNamespaceHierarchy.h ( OP Library, C++)
7  *
8  * COMMENTS: A class that manages the hierarchy (precedence order)
9  * of the operator type namespaces.
10  */
11 
12 #ifndef __OP_OpNamespaceHierarchy__
13 #define __OP_OpNamespaceHierarchy__
14 
15 #include "OP_API.h"
16 #include <UT/UT_SymbolTable.h>
17 
18 class UT_StringArray;
19 class op_OpPrefEntryComparator;
20 class op_OpPrecedenceList;
21 
22 
23 /// Implements an operator name resolution mechanism for unquallified (or
24 /// not fully qualified) operator names (ie, finds a full operator name with a
25 /// namespace and version tags, given a partial operatorn name, like just the
26 /// core name, or core name with a namespace but no version, where several
27 /// candidates may exist).
29 {
30 public:
31  // Constructor and destructor.
34 
35  /// Builds the operator definition hierarchy.
36  ///
37  /// @param hierarchy The string enumerating the namespace hierarchy.
38  /// @parm table_name The name of the operator table for which the
39  /// hierarchy is build.
40  void buildHierarchy( const char *hierarchy,
41  const char *table_name );
42 
43  /// Updates the hierarchy when an operator has been added to the table.
44  void handleOperatorAdded( const char *op_name );
45 
46  /// Updates the hierarchy when an operator has been removed from the table.
47  void handleOperatorRemoved( const char *op_name );
48 
49  /// Resolves a given optype name to a preferred optype name, in case
50  /// the given name is ambiguous and has several operator definition
51  /// candidates. For fully qualified or unambiguous names the method
52  /// will return the given argument.
53  ///
54  /// @param op_name The operator type name to resolve.
55  /// @param network_scope_stack The array of subnet optype names (
56  /// with the table name) inside which the operator
57  /// node would be created. The first element in the
58  /// array is the immediate parent, the second is
59  /// the granparent subnet, etc).
60  ///
61  /// @return The preferred operator type name for the given name.
62  const char * findPreferredOpName( const char *op_name,
63  const UT_StringArray *network_scope_stack);
64 
65  /// Obtains a list of available operator names that have the same base
66  /// (core) name as the given operator.
67  /// If scope network name is not NULL, the list includes only operators
68  /// whose nodes can be created in one of these networks (since they
69  /// represent the stack of nested scopes). Otherwise all operators are
70  /// included.
71  /// The list is sorted according to the descending precedence order.
72  void getPrecedenceOrder( UT_StringArray &precedence_order,
73  const char *op_name,
74  const UT_StringArray *network_scope_stack);
75 private:
76  /// @{
77  /// Helper method to access the precedence list for an operator.
78  op_OpPrecedenceList * getPrecedenceList( const char *op_name );
79  op_OpPrecedenceList * getOrCreatePrecedenceList( const char *op_name );
80  /// @}
81 
82 private:
83  /// The comparator used for sorting the precedence lists
84  op_OpPrefEntryComparator * myComparator;
85 
86  /// Map from the core operator name to the list of operators ordered
87  /// in descending preference order.
88  UT_SymbolMap<op_OpPrecedenceList *> myPreferenceLists;
89 };
90 
91 #endif
92 
#define OP_API
Definition: OP_API.h:10