Qt 4.8
Classes | Public Functions | Protected Functions | Private Types | Properties | List of all members
QDeclarativeTypeNameCache Class Reference

#include <qdeclarativetypenamecache_p.h>

Inheritance diagram for QDeclarativeTypeNameCache:
QDeclarativeRefCount QDeclarativeCleanup

Classes

struct  Data
 
struct  RData
 

Public Functions

void add (const QString &, int)
 
void add (const QString &, QDeclarativeType *)
 
void add (const QString &, QDeclarativeTypeNameCache *)
 
Datadata (const QString &) const
 
Datadata (const QScriptDeclarativeClass::Identifier &id) const
 
 QDeclarativeTypeNameCache (QDeclarativeEngine *)
 
virtual ~QDeclarativeTypeNameCache ()
 
- Public Functions inherited from QDeclarativeRefCount
void addref ()
 
 QDeclarativeRefCount ()
 
void release ()
 
virtual ~QDeclarativeRefCount ()
 
- Public Functions inherited from QDeclarativeCleanup
 QDeclarativeCleanup (QDeclarativeEngine *)
 
virtual ~QDeclarativeCleanup ()
 

Protected Functions

virtual void clear ()
 

Private Types

typedef QHash< QScriptDeclarativeClass::Identifier, RData * > IdentifierCache
 
typedef QHash< QString, RData * > StringCache
 

Properties

QDeclarativeEngineengine
 
IdentifierCache identifierCache
 
StringCache stringCache
 

Detailed Description

Definition at line 65 of file qdeclarativetypenamecache_p.h.

Typedefs

◆ IdentifierCache

Definition at line 94 of file qdeclarativetypenamecache_p.h.

◆ StringCache

Definition at line 93 of file qdeclarativetypenamecache_p.h.

Constructors and Destructors

◆ QDeclarativeTypeNameCache()

QDeclarativeTypeNameCache::QDeclarativeTypeNameCache ( QDeclarativeEngine e)

Definition at line 48 of file qdeclarativetypenamecache.cpp.

50 {
51 }
QDeclarativeCleanup(QDeclarativeEngine *)

◆ ~QDeclarativeTypeNameCache()

QDeclarativeTypeNameCache::~QDeclarativeTypeNameCache ( )
virtual

Definition at line 53 of file qdeclarativetypenamecache.cpp.

54 {
55  clear();
56 }

Functions

◆ add() [1/3]

void QDeclarativeTypeNameCache::add ( const QString name,
int  importedScriptIndex 
)

Definition at line 66 of file qdeclarativetypenamecache.cpp.

Referenced by cacheForNamespace(), QDeclarativeCompiler::compileTree(), and QDeclarativeImports::populateCache().

67 {
68  if (stringCache.contains(name))
69  return;
70 
72 
73  RData *data = new RData;
74  // ### Use typename class
75  data->identifier = ep->objectClass->createPersistentIdentifier(name);
76  data->importedScriptIndex = importedScriptIndex;
77  stringCache.insert(name, data);
78  identifierCache.insert(data->identifier.identifier, data);
79 }
static QDeclarativeEnginePrivate * get(QDeclarativeEngine *e)
bool contains(const Key &key) const
Returns true if the hash contains an item with the key; otherwise returns false.
Definition: qhash.h:872
PersistentIdentifier createPersistentIdentifier(const QString &)
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
QDeclarativeObjectScriptClass * objectClass
Data * data(const QString &) const

◆ add() [2/3]

void QDeclarativeTypeNameCache::add ( const QString name,
QDeclarativeType type 
)

Definition at line 81 of file qdeclarativetypenamecache.cpp.

82 {
83  if (stringCache.contains(name))
84  return;
85 
87 
88  RData *data = new RData;
89  // ### Use typename class
90  data->identifier = ep->objectClass->createPersistentIdentifier(name);
91  data->type = type;
92  stringCache.insert(name, data);
93  identifierCache.insert(data->identifier.identifier, data);
94 }
int type
Definition: qmetatype.cpp:239
static QDeclarativeEnginePrivate * get(QDeclarativeEngine *e)
bool contains(const Key &key) const
Returns true if the hash contains an item with the key; otherwise returns false.
Definition: qhash.h:872
PersistentIdentifier createPersistentIdentifier(const QString &)
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
QDeclarativeObjectScriptClass * objectClass
Data * data(const QString &) const

◆ add() [3/3]

void QDeclarativeTypeNameCache::add ( const QString name,
QDeclarativeTypeNameCache typeNamespace 
)

Definition at line 96 of file qdeclarativetypenamecache.cpp.

97 {
98  if (stringCache.contains(name))
99  return;
100 
102 
103  RData *data = new RData;
104  // ### Use typename class
105  data->identifier = ep->objectClass->createPersistentIdentifier(name);
106  data->typeNamespace = typeNamespace;
107  stringCache.insert(name, data);
108  identifierCache.insert(data->identifier.identifier, data);
109  typeNamespace->addref();
110 }
static QDeclarativeEnginePrivate * get(QDeclarativeEngine *e)
bool contains(const Key &key) const
Returns true if the hash contains an item with the key; otherwise returns false.
Definition: qhash.h:872
PersistentIdentifier createPersistentIdentifier(const QString &)
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
QDeclarativeObjectScriptClass * objectClass
Data * data(const QString &) const

◆ clear()

void QDeclarativeTypeNameCache::clear ( )
protectedvirtual

Implements QDeclarativeCleanup.

Definition at line 58 of file qdeclarativetypenamecache.cpp.

Referenced by ~QDeclarativeTypeNameCache().

59 {
62  identifierCache.clear();
63  engine = 0;
64 }
void clear()
Removes all items from the hash.
Definition: qhash.h:574
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
Definition: qalgorithms.h:319

◆ data() [1/2]

QDeclarativeTypeNameCache::Data * QDeclarativeTypeNameCache::data ( const QString id) const

◆ data() [2/2]

QDeclarativeTypeNameCache::Data * QDeclarativeTypeNameCache::data ( const QScriptDeclarativeClass::Identifier id) const
inline

Definition at line 111 of file qdeclarativetypenamecache_p.h.

112 {
113  return identifierCache.value(id);
114 }

Properties

◆ engine

QDeclarativeEngine* QDeclarativeTypeNameCache::engine
private

Definition at line 98 of file qdeclarativetypenamecache_p.h.

Referenced by add(), and clear().

◆ identifierCache

IdentifierCache QDeclarativeTypeNameCache::identifierCache
private

Definition at line 97 of file qdeclarativetypenamecache_p.h.

Referenced by add(), clear(), and data().

◆ stringCache

StringCache QDeclarativeTypeNameCache::stringCache
private

Definition at line 96 of file qdeclarativetypenamecache_p.h.

Referenced by add(), clear(), and data().


The documentation for this class was generated from the following files: