libPropertyBranch 2.0(r200)
Manages Tree-Like Paramter Sets

PropertyBranch.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2008 by Matthias Nagl   *
00003  *   mnagl@uni-goettingen.de   *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 #ifndef PropertyBranch_H
00021 #define PropertyBranch_H
00022 
00033 #include <PropertyBranchInterface.h>
00034 #include <QReadWriteLock>
00035 #include <QReadLocker>
00036 #include <QWriteLocker>
00037 #include <QMutex>
00038 #include <QSet>
00039 
00040 #if defined(PROPERTYBRANCHES_LIBRARY)
00041 #  define PB_EXPORT Q_DECL_EXPORT
00042 #else
00043 #  define PB_EXPORT Q_DECL_IMPORT
00044 #endif
00045 
00049 class PB_EXPORT PropertyBranch : public virtual PropertyBranchInterface
00050 {
00051   public:
00052     PropertyBranch();
00053     ~PropertyBranch();
00054 
00056     virtual void setParentBranch(PropertyBranchInterface *p = 0);
00057     virtual PropertyBranchInterface * parentBranch() { QReadLocker l(&mtxparents); return pp; }
00058     virtual const PropertyBranchInterface * parentBranch() const { QReadLocker l(&mtxparents); return pp; }
00059     virtual void setBranchName(QString name);
00060     virtual QString branchName() const { QReadLocker l(&mtxparams); return n; }
00061     virtual QStringList branchNamePath() const;
00062     virtual void setQSettingsSubBranch(QString qsprefix = QString()) { QWriteLocker l(&mtxparams); qsp = qsprefix; }
00063     virtual QString qSettingsSubBranch() const { QReadLocker l(&mtxparams); return qsp; }
00064     virtual QString qSettingsPath() const;
00065     virtual void setBranchProperty(TransmittableProperty *p);
00066     virtual TransmittableProperty * transmittableBranchProperty() const;
00068     virtual void forwardPropertyUpdate(TransmittablePropertyData &u);
00070     virtual void forwardConfirmationData(const TransmittablePropertyData *d) const;
00072     virtual void forwardNewProperty(const TransmittableProperty *p) const;
00074     virtual void forwardChildProperties() const;
00076     virtual QList<const TransmittableProperty*> childProperties() const;
00078     virtual void addChild(PropertyBranchInterface *child) { QWriteLocker l(&mtxchildren); c << child; }
00079     virtual void removeChild(PropertyBranchInterface *child) { QWriteLocker l(&mtxchildren); c.removeAll(child); }
00081     virtual void addProperty(TransmittableProperty *property) const;
00082     virtual void removeProperty(TransmittableProperty *property) const;
00084     virtual void childPropertyChanged(TransmittableProperty *p) { QReadLocker l(&mtxparents); if (pp!=0) pp->childPropertyChanged(p); }
00085 
00086   protected:
00088     virtual void propertyChanged(TransmittableProperty *p) { QReadLocker l(&mtxparents); if (pp!=0) pp->childPropertyChanged(p); }
00089     mutable QReadWriteLock mtxchildren, mtxparents, mtxparams;
00090     mutable QMutex updtmutex;
00091     mutable TransmittableProperty *tp;
00092 
00093   private:
00094     QString n;
00095     PropertyBranchInterface *pp;
00096     QString qsp;
00097     mutable bool selfmadeproperty;
00098     QList<PropertyBranchInterface*> c;
00099     mutable QList<TransmittableProperty*> props;
00100 };
00101 
00102 #endif
 All Classes Namespaces Files Functions Variables Enumerations Properties Friends Defines