HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_ThingList.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: UT_ThingList.h ( UT Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __UT_ThingList__
12 #define __UT_ThingList__
13 
14 #include "UT_API.h"
15 #include "UT_Thing.h"
16 #include "UT_Hash.h"
17 #include "UT_NonCopyable.h"
18 #include "UT_SmallObject.h"
19 
20 #include <SYS/SYS_Deprecated.h>
21 #include <stdio.h>
22 
24 
30 {
31 public:
34  UT_ThingEntry *next;
35 };
36 
37 class SYS_DEPRECATED_REPLACE(16.0, "std::list") UT_API UT_ThingList {
38 public:
39  UT_ThingList();
40  ~UT_ThingList();
41 
43 
44  // if 'ordered' is true, you must define UT_Hash::strcmp properly,
45  // to return -1, 0 and 1 based on <, = or >; not just 0 or 1.
46  int insertEntry(const UT_Hash &name, const UT_Thing & value,
47  bool ordered = false);
48  int findEntry(const UT_Hash &name, UT_Thing *valuep,
49  bool ordered = false) const;
50  int findEntry(const UT_Hash &name, UT_Thing *valuep,
51  const UT_Hash **namep, bool ordered = false) const;
52  UT_Thing &getEntry(const UT_Hash &name, int *created = 0,
53  bool ordered = false);
54  int deleteEntry(const UT_Hash &name,
55  bool ordered = false);
56 
57  const UT_Hash & getHashReference(const UT_Hash &name, int *created = 0,
58  bool ordered = false);
59 
60  int count() const;
61  int traverse(int (*function)(UT_Thing &, const UT_Hash &, void *),
62  void *data) const;
63 
64  unsigned entries() const;
65  unsigned empty() const; // Return true if empty
66 
67  int64 getMemoryUsage(bool inclusive) const;
68 
69 
70  // These methods are called by UT_HashTable when rebuilding the hash table.
72  // This function removes a UT_ThingEntry from the list and returns it
73  // so it can be modified and re-inserted to this list or another.
75  bool ordered);
76  // Inserts an entry into this list.
77  void insertThingEntry(UT_ThingEntry &thing_entry,
78  bool ordered);
79 
81  {
82  public:
84  : myCurrEntry(0) { }
86  { *this = src; }
87  ~traverser() { }
88 
89  UT_Thing &thing() const { return myCurrEntry->data; }
90  UT_Hash *hash() const { return myCurrEntry->name; }
91 
92  int operator==(const traverser &cmp) const
93  { return (myCurrEntry == cmp.myCurrEntry); }
94  int operator!=(const traverser &cmp) const
95  { return !(*this == cmp); }
96 
98  {
99  myCurrEntry = myCurrEntry->next;
100  return *this;
101  }
102 
104  {
105  myCurrEntry = src.myCurrEntry;
106  return *this;
107  }
108 
109  private:
111  : myCurrEntry(sym) { }
112 
113  UT_ThingEntry *myCurrEntry;
114 
115  friend class UT_ThingList;
116  };
117 
118  traverser begin() const { return traverser(symbols); }
119  traverser end() const { return traverser(); }
120 
121 private:
122  UT_ThingEntry *findOrCreate(const UT_Hash &name, int *created,
123  bool ordered);
124  UT_ThingEntry *symbols;
125 };
126 
128 
129 #endif
void insertThingEntry(UT_ThingEntry &thing_entry, bool ordered)
int traverse(int(*function)(UT_Thing &, const UT_Hash &, void *), void *data) const
int insertEntry(const UT_Hash &name, const UT_Thing &value, bool ordered=false)
#define SYS_DEPRECATED(__V__)
#define UT_SMALLOBJECT_PAGESIZE_DEFAULT
*get result *(waiting if necessary)*A common idiom is to fire a bunch of sub tasks at the and then *wait for them to all complete We provide a helper class
Definition: thread.h:623
int findEntry(const UT_Hash &name, UT_Thing *valuep, bool ordered=false) const
UT_Thing & getEntry(const UT_Hash &name, int *created=0, bool ordered=false)
traverser begin() const
Definition: UT_ThingList.h:118
unsigned entries() const
UT_Hash * hash() const
Definition: UT_ThingList.h:90
#define SYS_DEPRECATED_PUSH_DISABLE()
#define SYS_DEPRECATED_POP_DISABLE()
UT_ThingEntry * next
Definition: UT_ThingList.h:34
#define UT_API
Definition: UT_API.h:14
int64 getMemoryUsage(bool inclusive) const
Definition: UT_ThingList.h:25
int operator!=(const traverser &cmp) const
Definition: UT_ThingList.h:94
IMATH_HOSTDEVICE constexpr int cmp(T a, T b) IMATH_NOEXCEPT
Definition: ImathFun.h:84
traverser(const traverser &src)
Definition: UT_ThingList.h:85
UT_ThingEntry * removeFirstThingEntry()
#define SYS_DEPRECATED_REPLACE(__V__, __R__)
unsigned empty() const
#define UT_SMALLOBJECT_THREADSAFE_DEFAULT
UT_Thing & thing() const
Definition: UT_ThingList.h:89
UT_Hash * name
Definition: UT_ThingList.h:33
traverser end() const
Definition: UT_ThingList.h:119
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
long long int64
Definition: SYS_Types.h:116
GLuint const GLchar * name
Definition: glcorearb.h:786
int operator==(const traverser &cmp) const
Definition: UT_ThingList.h:92
#define UT_SMALLOBJECT_CLEANPAGES_DEFAULT
int count() const
traverser & operator++()
Definition: UT_ThingList.h:97
const UT_Hash & getHashReference(const UT_Hash &name, int *created=0, bool ordered=false)
const traverser & operator=(const traverser &src)
Definition: UT_ThingList.h:103
Definition: core.h:1131
Definition: format.h:895
UT_Thing data
Definition: UT_ThingList.h:32
GLenum src
Definition: glcorearb.h:1793
int deleteEntry(const UT_Hash &name, bool ordered=false)