00001 /* 00002 ReferenceHelper.h 00003 00004 Qore Programming Language 00005 00006 Copyright 2003 - 2009 David Nichols 00007 00008 This library is free software; you can redistribute it and/or 00009 modify it under the terms of the GNU Lesser General Public 00010 License as published by the Free Software Foundation; either 00011 version 2.1 of the License, or (at your option) any later version. 00012 00013 This library is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 Lesser General Public License for more details. 00017 00018 You should have received a copy of the GNU Lesser General Public 00019 License along with this library; if not, write to the Free Software 00020 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00021 */ 00022 00023 #ifndef _QORE_REFERENCEHELPER_H 00024 00025 #define _QORE_REFERENCEHELPER_H 00026 00028 00048 class ReferenceHelper { 00049 private: 00051 DLLLOCAL ReferenceHelper(const ReferenceHelper&); 00052 00054 DLLLOCAL ReferenceHelper& operator=(const ReferenceHelper&); 00055 00057 DLLLOCAL void *operator new(size_t); 00058 00059 protected: 00061 AbstractQoreNode **vp; 00062 00063 public: 00065 00069 DLLEXPORT ReferenceHelper(const ReferenceNode *ref, AutoVLock &vl, ExceptionSink *xsink); 00070 00072 DLLEXPORT ~ReferenceHelper(); 00073 00075 00077 DLLLOCAL operator bool() const { return vp != 0; } 00078 00080 00082 DLLLOCAL qore_type_t getType() const { return *vp ? (*vp)->getType() : NT_NOTHING; } 00083 00085 00102 DLLEXPORT AbstractQoreNode *getUnique(ExceptionSink *xsink); 00103 00105 00119 DLLEXPORT int assign(AbstractQoreNode *val, ExceptionSink *xsink); 00120 00122 00124 DLLEXPORT const AbstractQoreNode *getValue() const; 00125 00127 DLLEXPORT void swap(ReferenceHelper &other); 00128 }; 00129 00130 #endif