00001 /* 00002 * MKData.hpp 00003 * 00004 * Created on: Nov 25, 2011 00005 * Author: mriedel 00006 */ 00007 00008 #ifndef MKDATA_HPP_ 00009 #define MKDATA_HPP_ 00010 00011 #include <telekyb_defines/telekyb_defines.hpp> 00012 #include <tk_mkinterface/MKValue.hpp> 00013 #include <map> 00014 00015 #include <set> 00016 00017 namespace TELEKYB_NAMESPACE { 00018 00019 typedef std::map<MKInt,MKValue*> MKValueMap; 00020 00021 // MKDataListener 00022 class MKDataListener { 00023 public: 00024 virtual ~MKDataListener() {}; 00025 00026 // this is only called on updates 00027 virtual void dataValueUpdated(MKValue* value) = 0; 00028 // this is always called (set/update) 00029 //virtual void dataValueUpdated(MKValue* value) = 0; 00030 }; 00031 00032 class MKData { 00033 protected: 00034 MKValueMap valueMap; 00035 // Value Definition goes in here. 00036 void createMap(); 00037 00038 std::set<MKDataListener*> dataListenerSet; 00039 00040 // only by MKInterfaceConnection 00041 MKValue* setValue(MKSingleValuePacket packet); 00042 00043 void notifyMKDataListeners(MKValue* value); 00044 00045 public: 00046 MKData(); 00047 virtual ~MKData(); 00048 00049 MKValue* getValueByID(MKInt id) const; 00050 bool isMember(MKValue* value_) const; 00051 00052 void registerMKDataListener(MKDataListener* listener); 00053 void unRegisterMKDataListener(MKDataListener* listener); 00054 00055 00056 // Some collections of MKActiveIDs 00057 static MKActiveIDs getPattern(MKDataPattern pattern); 00058 // static is Accessor 00059 00060 // friend class 00061 friend class MKInterfaceConnection; 00062 00063 }; 00064 00065 } /* namespace telekyb */ 00066 #endif /* MKDATA_HPP_ */