1 #ifndef _VARIANT_TYPE_H_
2 #define _VARIANT_TYPE_H_
4 #include "abstractpropertytype.h"
5 #include "abstractroutingengine.h"
7 class AbstractDBusInterface;
9 class VariantType: public AbstractPropertyType
13 typedef function<void (boost::any)> SetterFunc;
21 VariantType(AbstractRoutingEngine* re, VehicleProperty::Property ambPropertyName, string propertyName, Access access);
25 GVariant* toVariant();
26 void fromVariant(GVariant *value);
28 bool operator == (VariantType & other)
30 return (other.dbusName() == dbusName()
31 && other.ambPropertyName() == ambPropertyName()
32 && other.sourceFilter() == sourceFilter()
33 && other.zoneFilter() == zoneFilter());
36 virtual void setSetterFunction(SetterFunc setterFunc)
38 mSetterFunc = setterFunc;
41 virtual std::string dbusName()
46 virtual std::string ambPropertyName()
51 virtual Access access()
56 void setSourceFilter(std::string filter)
60 void setZoneFilter(Zone::Type z)
65 std::string sourceFilter() { return sourceUuid; }
66 Zone::Type zoneFilter() { return zone; }
68 virtual void setValue(AbstractPropertyType* val)
73 mValue->quickCopy(val);
75 if(mUpdateFrequency == 0)
77 PropertyInfo info = routingEngine->getPropertyInfo(mValue->name, mValue->sourceUuid);
80 mUpdateFrequency = info.updateFrequency();
82 mUpdateFrequency = -1;
86 virtual void updateValue(AbstractPropertyType* val)
93 return mUpdateFrequency;
96 AbstractPropertyType* value()
101 std::string toString() const
106 void fromString(std::string str)
111 AbstractPropertyType * copy()
113 return new VariantType(routingEngine, name, mPropertyName, mAccess);
117 int mUpdateFrequency;
118 AbstractRoutingEngine* routingEngine;
119 string mPropertyName;
120 SetterFunc mSetterFunc;
122 AbstractPropertyType* mValue;
123 AbstractDBusInterface* mInterface;
126 void asyncReply(AsyncPropertyReply*);
132 typedef VariantType AbstractProperty;