Fact.h 2.7 KB
Newer Older
Don Gagne's avatar
Don Gagne committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
/*=====================================================================
 
 QGroundControl Open Source Ground Control Station
 
 (c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 
 This file is part of the QGROUNDCONTROL project
 
 QGROUNDCONTROL is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.
 
 QGROUNDCONTROL is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
 
 ======================================================================*/

/// @file
///     @author Don Gagne <don@thegagnes.com>

#ifndef Fact_H
#define Fact_H

#include "FactMetaData.h"

#include <QObject>
#include <QString>
#include <QVariant>
35
#include <QDebug>
Don Gagne's avatar
Don Gagne committed
36 37 38 39 40 41 42

/// @brief A Fact is used to hold a single value within the system.
class Fact : public QObject
{
    Q_OBJECT
    
public:
43
    Fact(int componentId, QString name, FactMetaData::ValueType_t type, QObject* parent = NULL);
Don Gagne's avatar
Don Gagne committed
44 45 46
    
    // Property system methods
    
47
    QString name(void) const;
48
    int componentId(void) const;
49 50
    QVariant value(void) const;
    QString valueString(void) const;
51
    void setValue(const QVariant& value);
52
    QVariant defaultValue(void);
53 54
	bool defaultValueAvailable(void);
    bool valueEqualsDefault(void);
55 56 57 58 59
    FactMetaData::ValueType_t type(void);
    QString shortDescription(void);
    QString longDescription(void);
    QString units(void);
    QVariant min(void);
60 61
    QVariant max(void);    
    QString group(void);
Don Gagne's avatar
Don Gagne committed
62 63
    
    /// Sets the meta data associated with the Fact.
64
    void setMetaData(FactMetaData* metaData);
Don Gagne's avatar
Don Gagne committed
65
    
66 67
    void _containerSetValue(const QVariant& value);
    
Don Gagne's avatar
Don Gagne committed
68 69 70 71
signals:
    /// QObject Property System signal for value property changes
    ///
    /// This signal is only meant for use by the QT property system. It should not be connected to by client code.
72
    void valueChanged(QVariant value);
Don Gagne's avatar
Don Gagne committed
73 74 75
    
    /// Signalled when property has been changed by a call to the property write accessor
    ///
76
    /// This signal is meant for use by Fact container implementations.
Don Gagne's avatar
Don Gagne committed
77
    void _containerValueChanged(const QVariant& value);
Don Gagne's avatar
Don Gagne committed
78 79
    
private:
80
    QString                     _name;
81
    int                         _componentId;
82 83 84
    QVariant                    _value;
    FactMetaData::ValueType_t   _type;
    FactMetaData*               _metaData;
Don Gagne's avatar
Don Gagne committed
85 86 87
};

#endif