00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef _QORE_QOREOBJECT_H
00028
00029 #define _QORE_QOREOBJECT_H
00030
00031 class AutoVLock;
00032 class VRMutex;
00033 class BuiltinMethod;
00034
00036
00049 class QoreObject : public AbstractQoreNode {
00050 friend struct qore_object_private;
00051 friend class qore_object_lock_handoff_manager;
00052
00053 private:
00055 struct qore_object_private *priv;
00056
00057
00058 DLLLOCAL void doDeleteIntern(ExceptionSink *xsink);
00059 DLLLOCAL void cleanup(ExceptionSink *xsink, QoreHashNode *td);
00060 DLLLOCAL void addVirtualPrivateData(AbstractPrivateData *apd);
00061
00063 DLLLOCAL QoreObject(const QoreObject&);
00064
00066 DLLLOCAL QoreObject& operator=(const QoreObject&);
00067
00068 protected:
00070
00074 DLLEXPORT virtual bool derefImpl(ExceptionSink *xsink);
00075
00077
00079 DLLLOCAL virtual AbstractQoreNode *evalImpl(ExceptionSink *xsink) const;
00080
00082
00084 DLLLOCAL virtual AbstractQoreNode *evalImpl(bool &needs_deref, ExceptionSink *xsink) const;
00085
00087
00089 DLLLOCAL virtual int64 bigIntEvalImpl(ExceptionSink *xsink) const;
00090
00092
00094 DLLLOCAL virtual int integerEvalImpl(ExceptionSink *xsink) const;
00095
00097
00099 DLLLOCAL virtual bool boolEvalImpl(ExceptionSink *xsink) const;
00100
00102
00104 DLLLOCAL virtual double floatEvalImpl(ExceptionSink *xsink) const;
00105
00107 DLLLOCAL void customRefIntern() const;
00108
00110 DLLLOCAL virtual void customRef() const;
00111
00113 DLLLOCAL virtual void customDeref(ExceptionSink *xsink);
00114
00116 DLLLOCAL virtual ~QoreObject();
00117
00118 public:
00120
00124 DLLEXPORT QoreObject(const QoreClass *oc, QoreProgram *p);
00125
00127
00133 DLLEXPORT virtual int getAsString(QoreString &str, int foff, ExceptionSink *xsink) const;
00134
00136
00143 DLLEXPORT virtual QoreString *getAsString(bool &del, int foff, ExceptionSink *xsink) const;
00144
00146 DLLEXPORT virtual AbstractQoreNode *realCopy() const;
00147
00149
00153 DLLEXPORT virtual bool is_equal_soft(const AbstractQoreNode *v, ExceptionSink *xsink) const;
00154
00156
00160 DLLEXPORT virtual bool is_equal_hard(const AbstractQoreNode *v, ExceptionSink *xsink) const;
00161
00163 DLLEXPORT virtual const char *getTypeName() const;
00164
00166 DLLLOCAL static const char *getStaticTypeName() {
00167 return "object";
00168 }
00169
00171
00174 DLLEXPORT bool validInstanceOf(qore_classid_t cid) const;
00175
00177
00182 DLLEXPORT void setValue(const char *key, AbstractQoreNode *val, ExceptionSink *xsink);
00183
00185
00188 DLLEXPORT QoreListNode *getMemberList(ExceptionSink *xsink) const;
00189
00191
00195 DLLEXPORT void deleteMemberValue(const QoreString *key, ExceptionSink *xsink);
00196
00198
00202 DLLEXPORT void deleteMemberValue(const char *key, ExceptionSink *xsink);
00203
00205
00208 DLLEXPORT int size(ExceptionSink *xsink) const;
00209
00211
00215 DLLEXPORT bool compareSoft(const QoreObject *obj, ExceptionSink *xsink) const;
00216
00218
00222 DLLEXPORT bool compareHard(const QoreObject *obj, ExceptionSink *xsink) const;
00223
00225
00229 DLLEXPORT AbstractQoreNode *getReferencedMemberNoMethod(const char *mem, ExceptionSink *xsink) const;
00230
00232
00235 DLLEXPORT QoreHashNode *copyData(ExceptionSink *xsink) const;
00236
00238
00242 DLLEXPORT void mergeDataToHash(QoreHashNode *hash, ExceptionSink *xsink);
00243
00245
00249 DLLEXPORT void setPrivate(qore_classid_t key, AbstractPrivateData *pd);
00250
00252
00256 DLLEXPORT AbstractPrivateData *getReferencedPrivateData(qore_classid_t key, ExceptionSink *xsink) const;
00257
00259
00264 DLLEXPORT AbstractQoreNode *evalMethod(const QoreString *name, const QoreListNode *args, ExceptionSink *xsink);
00265
00267
00272 DLLEXPORT AbstractQoreNode *evalMethod(const char *name, const QoreListNode *args, ExceptionSink *xsink);
00273
00275
00280 DLLEXPORT AbstractQoreNode *evalMethod(const QoreMethod &method, const QoreListNode *args, ExceptionSink *xsink);
00281
00283
00286 DLLEXPORT void doDelete(ExceptionSink *xsink);
00287
00289
00293 DLLEXPORT const QoreClass *getClass(qore_classid_t cid) const;
00294
00296
00299 DLLEXPORT const QoreClass *getClass() const;
00300
00302
00305 DLLEXPORT const char *getClassName() const;
00306
00308
00311 DLLEXPORT bool isValid() const;
00312
00314
00317 DLLEXPORT QoreProgram *getProgram() const;
00318
00320
00323 DLLEXPORT bool isSystemObject() const;
00324
00326
00331 DLLEXPORT void tRef() const;
00332
00334
00337 DLLEXPORT void tDeref();
00338
00340
00348 DLLEXPORT AbstractQoreNode *getMemberValueNoMethod(const QoreString *key, AutoVLock *vl, ExceptionSink *xsink) const;
00349
00351
00357 DLLEXPORT AbstractQoreNode *getMemberValueNoMethod(const char *key, AutoVLock *vl, ExceptionSink *xsink) const;
00358
00360
00362 DLLEXPORT void deleteBlockerRef() const;
00363
00365
00369 DLLEXPORT void externalDelete(qore_classid_t key, ExceptionSink *xsink);
00370
00371 DLLLOCAL int getStatus() const;
00372
00374
00378 DLLLOCAL AbstractQoreNode *evalMember(const QoreString *member, ExceptionSink *xsink);
00379
00381
00385 DLLLOCAL void merge(const QoreHashNode *h, ExceptionSink *xsink);
00386
00388
00392 DLLLOCAL QoreHashNode *getRuntimeMemberHash(ExceptionSink *xsink) const;
00393
00394 DLLLOCAL class KeyNode *getReferencedPrivateDataNode(qore_classid_t key);
00395
00397
00401 DLLLOCAL AbstractPrivateData *getAndClearPrivateData(qore_classid_t key, ExceptionSink *xsink);
00402
00404
00409 DLLLOCAL AbstractQoreNode *evalBuiltinMethodWithPrivateData(BuiltinMethod *meth, const QoreListNode *args, ExceptionSink *xsink);
00410
00412 DLLLOCAL void evalCopyMethodWithPrivateData(BuiltinMethod *meth, QoreObject *self, const char *class_name, ExceptionSink *xsink);
00413
00415
00419 DLLLOCAL void addPrivateDataToString(QoreString *str, ExceptionSink *xsink) const;
00420
00422
00425 DLLLOCAL void obliterate(ExceptionSink *xsink);
00426
00428
00432 DLLLOCAL void defaultSystemDestructor(qore_classid_t classID, ExceptionSink *xsink);
00433
00435
00442 DLLLOCAL AbstractQoreNode **getMemberValuePtr(const QoreString *key, AutoVLock *vl, ExceptionSink *xsink) const;
00443
00445
00451 DLLLOCAL AbstractQoreNode **getMemberValuePtr(const char *key, AutoVLock *vl, ExceptionSink *xsink) const;
00452
00454
00461 DLLLOCAL AbstractQoreNode **getExistingValuePtr(const QoreString *mem, AutoVLock *vl, ExceptionSink *xsink) const;
00462
00464
00470 DLLLOCAL AbstractQoreNode **getExistingValuePtr(const char *mem, AutoVLock *vl, ExceptionSink *xsink) const;
00471
00472
00473 DLLLOCAL QoreHashNode *getSlice(const QoreListNode *value_list, ExceptionSink *xsink) const;
00474
00476 DLLLOCAL QoreObject(const QoreClass *oc, QoreProgram *p, QoreHashNode *d);
00477
00479 DLLLOCAL bool evalDeleteBlocker(BuiltinMethod *meth);
00480
00482 DLLLOCAL bool hasMemberNotification() const;
00483
00485 DLLLOCAL void execMemberNotification(const char *member, ExceptionSink *xsink);
00486
00488 DLLLOCAL VRMutex *getClassSyncLock();
00489 };
00490
00491 #endif