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;
36 typedef function<void (boost::any)> SetterFunc;
49 VariantType(AbstractRoutingEngine* re, VehicleProperty::Property ambPropertyName, std::string propertyName, Access access);
50 virtual ~VariantType();
52 bool operator == (VariantType & other)
54 return (other.name() == name()
55 && other.ambPropertyName() == ambPropertyName()
56 && other.sourceFilter() == sourceFilter()
57 && other.zoneFilter() == zoneFilter());
60 virtual void setSetterFunction(SetterFunc setterFunc)
62 mSetterFunc = setterFunc;
65 virtual const string signature()
67 GVariant* var = toVariant();
70 const string s = g_variant_get_type_string(var);
80 virtual VehicleProperty::Property ambPropertyName()
82 return mAmbPropertyName;
85 virtual Access access()
90 void setSourceFilter(std::string filter) { mSourceFilter = filter; }
91 void setZoneFilter(Zone::Type zone)
99 std::string sourceFilter() { return mSourceFilter; }
100 Zone::Type zoneFilter() { return mZoneFilter; }
102 virtual GVariant* toVariant();
103 virtual void fromVariant(GVariant *value);
108 return mValue->timestamp;
115 return mValue->sequence;
119 virtual void setValue(AbstractPropertyType* val)
126 mValue = val->copy();
130 mValue->quickCopy(val);
133 if(mUpdateFrequency == 0)
135 PropertyInfo info = routingEngine->getPropertyInfo(mValue->name, mValue->sourceUuid);
138 mUpdateFrequency = info.updateFrequency();
140 mUpdateFrequency = -1;
144 virtual void updateValue(AbstractPropertyType* val)
149 int updateFrequency()
151 return mUpdateFrequency;
154 AbstractPropertyType* value()
163 std::string mSourceFilter;
164 Zone::Type mZoneFilter;
165 int mUpdateFrequency;
166 AbstractRoutingEngine* routingEngine;
167 string mPropertyName;
168 VehicleProperty::Property mAmbPropertyName;
169 SetterFunc mSetterFunc;
171 AbstractPropertyType* mValue;
172 AbstractDBusInterface* mInterface;
178 #endif // ABSTRACTPROPERTY_H