2 Copyright (C) 2012 Intel Corporation
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with this library; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 #ifndef VARIANTTYPE_H_
20 #define VARIANTTYPE_H_
24 #include <boost/any.hpp>
28 #include "abstractpropertytype.h"
29 #include "abstractroutingengine.h"
30 #include "vehicleproperty.h"
32 class AbstractDBusInterface;
45 VariantType(AbstractRoutingEngine* re, VehicleProperty::Property ambPropertyName, std::string propertyName, Access access);
46 virtual ~VariantType();
48 bool operator == (VariantType & other)
50 return (other.name() == name()
51 && other.ambPropertyName() == ambPropertyName()
52 && other.sourceFilter() == sourceFilter()
53 && other.zoneFilter() == zoneFilter());
56 virtual const string signature()
58 GVariant* var = toVariant();
61 const string s = g_variant_get_type_string(var);
71 virtual VehicleProperty::Property ambPropertyName()
73 return mAmbPropertyName;
76 virtual Access access()
81 void setSourceFilter(std::string filter) { mSourceFilter = filter; }
82 void setZoneFilter(Zone::Type zone)
90 std::string sourceFilter() { return mSourceFilter; }
91 Zone::Type zoneFilter() { return mZoneFilter; }
93 virtual GVariant* toVariant();
94 virtual void fromVariant(GVariant *value, std::function<void (bool, AsyncPropertyReply::Error)> callback);
99 return mValue->timestamp;
106 return mValue->sequence;
110 virtual void setValue(AbstractPropertyType* val)
117 mValue = val->copy();
121 mValue->quickCopy(val);
124 if(mUpdateFrequency == 0)
126 PropertyInfo info = routingEngine->getPropertyInfo(mValue->name, mValue->sourceUuid);
129 mUpdateFrequency = info.updateFrequency();
131 mUpdateFrequency = -1;
135 virtual void updateValue(AbstractPropertyType* val)
140 int updateFrequency()
142 return mUpdateFrequency;
145 AbstractPropertyType* value()
154 std::string mSourceFilter;
155 Zone::Type mZoneFilter;
156 int mUpdateFrequency;
157 AbstractRoutingEngine* routingEngine;
158 string mPropertyName;
159 VehicleProperty::Property mAmbPropertyName;
161 AbstractPropertyType* mValue;
162 AbstractDBusInterface* mInterface;
168 #endif // ABSTRACTPROPERTY_H