GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
gmTrackedValueAccessor.h
Go to the documentation of this file.
1/************************************************************************
2**
3** Copyright (C) 2014 by Carlos Augusto Teixera Mendes
4** All rights reserved.
5**
6** This file is part of the "GeMA" software. It's use should respect
7** the terms in the license agreement that can be found together
8** with this source code.
9** It is provided AS IS, with NO WARRANTY OF ANY KIND,
10** INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR
11** A PARTICULAR PURPOSE.
12**
13************************************************************************/
14
23#ifndef _GEMA_TRACKED_VALUE_ACCESSOR_H_
24#define _GEMA_TRACKED_VALUE_ACCESSOR_H_
25
26#include "gmValueAccessor.h"
27#include "gmValueSet.h"
28
29#include <QObject>
30
31
38{
39 Q_OBJECT
40
41public:
50 GmTrackedValueAccessor(GmValueInfo* info, const GmLogCategory& logger, UnitConverter* conv, QString desiredUnit)
51 : GmValueAccessorBase(info, logger, conv, desiredUnit), _locked(false), _sindex(-1) {}
52
55
58
63 virtual void updateValueSetData(GmValueSetData* vsd) = 0;
64
72 void setTrackIndex(int sindex, bool locked) { _sindex = sindex; _locked = locked; }
73
75 int trackIndex() const { return _sindex; }
76
78 bool trackIndexLocked() const { return _locked; }
79
80private slots:
81
86 void setDataChanged(const GmValueSet* vs)
87 {
88 assert(_sindex >= 0); // setTrackIndex must have been called if this accessor is connected to a signal
89 updateValueSetData(vs->valueSetData(_sindex, _locked));
90 }
91
92private:
93 bool _locked;
94 int _sindex;
95};
96
97
98#endif
99
100
Class representing a category with multiple logging levels.
Definition gmLog.h:58
Auxiliary class responisble for allowing a value accessor to track changes to the referenced value se...
Definition gmTrackedValueAccessor.h:38
void setTrackIndex(int sindex, bool locked)
Provides the tracked accessor with the index/state information that it needs to update its ValueSetDa...
Definition gmTrackedValueAccessor.h:72
void setDataChanged(const GmValueSet *vs)
Slot called when a value set has a change in its value set data buffers. Called both when a saveState...
Definition gmTrackedValueAccessor.h:86
int trackIndex() const
Returns the current track index as defined by the last call to setTrackIndex()
Definition gmTrackedValueAccessor.h:75
GmTrackedValueAccessor(GmValueInfo *info, const GmLogCategory &logger, UnitConverter *conv, QString desiredUnit)
Constructor.
Definition gmTrackedValueAccessor.h:50
int _sindex
The locked state number if _locked == true. The ValueSetData index inside the ValueSet otherwise.
Definition gmTrackedValueAccessor.h:94
virtual ~GmTrackedValueAccessor()
Virtual destructor.
Definition gmTrackedValueAccessor.h:54
virtual void updateValueSetData(GmValueSetData *vsd)=0
Updates the value set data that this accessor is tied to. The new accessor shares the same info objec...
bool trackIndexLocked() const
Returns if the track index is locked or not.
Definition gmTrackedValueAccessor.h:78
bool _locked
Is this an accessor locked to a state number?
Definition gmTrackedValueAccessor.h:93
virtual GmValueSetData * valueSetData()=0
Returns the value set data that this accessor is tied to.
An implementation of basic attributes and functions that should be common for most value accessor imp...
Definition gmValueAccessor.h:367
Auxiliar class used to store the definition of a value. It can be used to store informations about st...
Definition gmValueInfo.h:132
The generic interface implemented by every GmValueSetData object. Its purpose is to provide a base cl...
Definition gmValueSetData.h:58
Basic class used to store sets of values, bound to a common definition, on behalf of another object (...
Definition gmValueSet.h:54
GmValueSetData * valueSetData(int sindex, bool locked) const
Returns the value set data object associated with the given index. If locked == true,...
Definition gmValueSet.h:115
#define GMC_API_EXPORT
Macro for controlling if the class is being exported (GEMA_CORE_LIB defined) or imported (GEMA_CORE_L...
Definition gmCoreConfig.h:35
Declaration of the GmValueAccessor interface and GmValueAccessorBase class.
Declaration of the GmValueSet class.