QGpCoreTools/XMLMember.h
Go to the documentation of this file.
00001 /***************************************************************************
00002 **
00003 **  This file is part of QGpCoreTools.
00004 **
00005 **  This library is free software; you can redistribute it and/or
00006 **  modify it under the terms of the GNU Lesser General Public
00007 **  License as published by the Free Software Foundation; either
00008 **  version 2.1 of the License, or (at your option) any later version.
00009 **
00010 **  This file is distributed in the hope that it will be useful, but WITHOUT
00011 **  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 **  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
00013 **  License for more details.
00014 **
00015 **  You should have received a copy of the GNU Lesser General Public
00016 **  License along with this library; if not, write to the Free Software
00017 **  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00018 **
00019 **  See http://www.geopsy.org for more information.
00020 **
00021 **  Created : 2009-06-07
00022 **  Authors :
00023 **    Marc Wathelet
00024 **    Marc Wathelet (LGIT, Grenoble, France)
00025 **
00026 ***************************************************************************/
00027 
00028 #ifndef XMLMEMBER_H
00029 #define XMLMEMBER_H
00030 
00031 #include "XMLContext.h"
00032 #include "QGpCoreToolsDLLExport.h"
00033 
00034 namespace QGpCoreTools {
00035 
00036 class XMLClass;
00037 
00038 class QGPCORETOOLS_EXPORT XMLMember
00039 {
00040 public:
00041   inline XMLMember(int memberID, XMLContext * context=0);
00042   inline XMLMember(XMLClass * child, bool temp=false, XMLContext * context=0);
00043 
00044   enum SpecialPublicMemberIDs {Unknown=-1, Skip=-2};
00045 
00046   inline void operator=(const XMLMember& o);
00047   inline XMLMember& operator+(int idOffset);
00048   inline void reset();
00049 
00050   bool isValidMember() {return _memberID>Unknown;}
00051   bool isSkipMember() {return _memberID==Skip;}
00052   int memberID() {return _memberID;}
00053   XMLClass * child() {return _child;}
00054   XMLContext * context(XMLContext * defaultContext) const {return _context ? _context : defaultContext;}
00055   inline void release();
00056 private:
00057   enum SpecialPrivateMemberIDs {PermanentChild=-3, TemporaryChild=-4};
00058   XMLContext * _context;
00059   XMLClass * _child;
00060   int _memberID;
00061 };
00062 
00063 inline XMLMember::XMLMember(int memberID, XMLContext * context)
00064 {
00065   _context=context;
00066   _child=0;
00067   _memberID=memberID;
00068 }
00069 
00070 inline XMLMember::XMLMember(XMLClass * child, bool temp, XMLContext * context)
00071 {
00072   _context=context;
00073   _child=child;
00074   _memberID=temp ? TemporaryChild : PermanentChild;
00075 }
00076 
00077 inline void XMLMember::operator=(const XMLMember& o)
00078 {
00079   _context=o._context;
00080   _child=o._child;
00081   _memberID=o._memberID;
00082 }
00083 
00084 inline XMLMember& XMLMember::operator+(int idOffset)
00085 {
00086   if(_memberID>Unknown) _memberID+=idOffset;
00087   return *this;
00088 }
00089 
00090 inline void XMLMember::reset()
00091 {
00092   _context=0;
00093   _child=0;
00094   _memberID=Unknown;
00095 }
00096 
00097 } // namespace QGpCoreTools
00098 
00099 #endif // XMLMEMBER_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines