check for property changed in core, but don't use right now 24/2524/1
authorKevron Rees <tripzero.kev@gmail.com>
Tue, 27 Nov 2012 01:00:01 +0000 (17:00 -0800)
committerKevron Rees <tripzero.kev@gmail.com>
Tue, 27 Nov 2012 01:00:01 +0000 (17:00 -0800)
ambd/core.cpp
ambd/core.h
lib/abstractpropertytype.h

index b3098cf..02aa4cb 100644 (file)
@@ -148,6 +148,18 @@ void Core::updateProperty(VehicleProperty::Property property, AbstractPropertyTy
 
        propertiesPerSecond++;
 
+       /*if(previousValueMap.find(property) != previousValueMap.end())
+       {
+               std::string v = previousValueMap[property];
+               if(v == value->toString())
+               {
+                       ///no change from last value;
+                       return;
+               }
+       }
+
+       previousValueMap[property] = value->toString();*/
+
        for(SinkList::iterator itr = list.begin(); itr != list.end(); itr++)
        {
                (*itr)->propertyChanged(property, value, uuid, timestamp, sequence);
index 5c245f6..6afe7b2 100644 (file)
@@ -61,6 +61,8 @@ private:
        int propertiesPerSecond;
        
        std::map<VehicleProperty::Property, SinkList> propertySinkMap;
+
+       std::map<VehicleProperty::Property, std::string> previousValueMap;
     
 };
 
index 777cd3b..c9297e5 100644 (file)
 class AbstractPropertyType
 {
 public:
-       virtual std::string toString() = 0;
+       virtual std::string toString() const = 0;
 
        virtual void fromString(std::string)= 0;
 
+       virtual AbstractPropertyType* copy() = 0;
+
        void setValue(boost::any val)
        {
                mValue = val;
@@ -86,6 +88,11 @@ public:
                else throw std::runtime_error("value cannot be empty");
        }
 
+       AbstractPropertyType* copy()
+       {
+               return new BasicPropertyType<T>(*this);
+       }
+
        void fromString(std::string val)
        {
                if(!val.empty() && val != "")
@@ -94,7 +101,7 @@ public:
                }
        }
 
-       std::string toString()
+       std::string toString() const
        {
                std::stringstream stream;
                stream<<value<T>();
@@ -150,8 +157,12 @@ public:
                setValue(val);
        }
 
+       AbstractPropertyType* copy()
+       {
+               return new StringPropertyType(*this);
+       }
 
-       std::string toString()
+       std::string toString() const
        {
                return value<std::string>();
        }