From 75504f214243ec7f4dc2ed967cafe52e395c0a7f Mon Sep 17 00:00:00 2001 From: Kevron Rees Date: Mon, 13 Aug 2012 12:59:02 -0700 Subject: [PATCH] missed these files --- ambd/core.cpp | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++ ambd/core.h | 47 ++++++++++++++++++++++++++++++++++++++ lib/listplusplus.cpp | 21 +++++++++++++++++ lib/listplusplus.h | 58 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 190 insertions(+) create mode 100644 ambd/core.cpp create mode 100644 ambd/core.h create mode 100644 lib/listplusplus.cpp create mode 100644 lib/listplusplus.h diff --git a/ambd/core.cpp b/ambd/core.cpp new file mode 100644 index 0000000..c94eed3 --- /dev/null +++ b/ambd/core.cpp @@ -0,0 +1,64 @@ +/* + Copyright (C) 2012 Intel Corporation + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + + +#include "core.h" +#include +#include "listplusplus.h" + +using namespace std::placeholders; + +Core::Core(SourceList sources, SinkList sinks) +: mSources(sources), mSinks(sinks) +{ + ///Hook up signals for each source + + for(SourceList::iterator itr = mSources.begin(); itr!=mSources.end(); itr++) + { + auto supportedChangedCb = std::bind(&Core::supportedChanged,this, _1, _2); + (*itr)->setSupportedChangedCb(supportedChangedCb); + + auto propChangedDb = std::bind(&Core::propertyChanged, this, _1, _2); + (*itr)->setPropertyChangedCb(propChangedDb); + } +} + + +void Core::supportedChanged(PropertyList added, PropertyList removed) +{ + + for(PropertyList::iterator itr = added.begin(); itr != added.end(); itr++) + { + if(ListPlusPlus(added).contains(*itr)) + { + mMasterPropertyList.push_back(*itr); + } + } + + for(PropertyList::iterator itr = removed.begin(); itr != removed.end(); itr++) + { + ListPlusPlus(removed).removeOne(*itr); + } + +} + +void Core::propertyChanged(VehicleProperty::Property property, boost::any value) +{ + +} + diff --git a/ambd/core.h b/ambd/core.h new file mode 100644 index 0000000..57fecfc --- /dev/null +++ b/ambd/core.h @@ -0,0 +1,47 @@ +/* + Copyright (C) 2012 Intel Corporation + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + + +#ifndef CORE_H +#define CORE_H + +#include "abstractsink.h" +#include "abstractsource.h" + +class Core +{ + +public: + Core(SourceList sources, SinkList sinks); + + +private: ///methods + + void supportedChanged(PropertyList added, PropertyList removed); + + void propertyChanged(VehicleProperty::Property property, boost::any value); + +private: + PropertyList mMasterPropertyList; + + SourceList mSources; + SinkList mSinks; + +}; + +#endif // CORE_H diff --git a/lib/listplusplus.cpp b/lib/listplusplus.cpp new file mode 100644 index 0000000..1351491 --- /dev/null +++ b/lib/listplusplus.cpp @@ -0,0 +1,21 @@ +/* + Copyright (C) 2012 Intel Corporation + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + + +#include "listplusplus.h" + diff --git a/lib/listplusplus.h b/lib/listplusplus.h new file mode 100644 index 0000000..04d3655 --- /dev/null +++ b/lib/listplusplus.h @@ -0,0 +1,58 @@ +/* + Copyright (C) 2012 Intel Corporation + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + + +#ifndef LISTPLUSPLUS_H +#define LISTPLUSPLUS_H + +#include +#include + +template +class ListPlusPlus +{ +public: + + ListPlusPlus(std::list list) + :mList(list) + { + + } + + + void removeOne(T value) + { + typename std::list::iterator itr = std::find(mList.begin(), mList.end(), value); + + if (itr != mList.end()) + { + mList.erase(itr); + } + } + + + bool contains(T value) + { + return (std::find(mList.begin(), mList.end(), value) != mList.end()); + } + +private: + std::list mList; +}; + +#endif // LISTPLUSPLUS_H -- 2.7.4