automotive-message-broker  0.13.1
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
ambpluginimpl.h
1 /*
2 Copyright (C) 2012 Intel Corporation
3 
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.
8 
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.
13 
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
17 */
18 
19 #ifndef _AMBPLUGINIMPL_H_
20 #define _AMBPLUGINIMPL_H_
21 
22 #include "abstractsource.h"
23 
37 {
38 
39 public:
45  AmbPluginImpl(AbstractRoutingEngine* re, const map<string, string>& config, AbstractSource &parent);
46  virtual ~AmbPluginImpl() { } /*LCOV_EXCL_LINE*/
47 
48  // aka AbstractSource:
49 public:
50 
56  virtual void getPropertyAsync(AsyncPropertyReply *reply);
57 
65 
72  virtual AsyncPropertyReply *setProperty(const AsyncSetPropertyRequest& request );
73 
79  virtual void subscribeToPropertyChanges(const VehicleProperty::Property& property);
80 
85  virtual void unsubscribeToPropertyChanges(const VehicleProperty::Property& property);
86 
91  virtual PropertyList supported() const;
92 
97  virtual int supportedOperations() const;
98 
105  virtual PropertyInfo getPropertyInfo(const VehicleProperty::Property & property);
106 
107  // aka AbstractSink:
108 public:
109 
113  virtual const std::string uuid() const = 0;
114 
120  virtual void propertyChanged(AbstractPropertyType* value);
121 
126  virtual void supportedChanged(const PropertyList& supportedProperties);
127 
132  virtual void init();
133 
134 protected:
135 
141  virtual AbstractPropertyType* findPropertyType(const VehicleProperty::Property& propertyName, const Zone::Type& zone = Zone::None);
142 
148  std::shared_ptr<AbstractPropertyType> addPropertySupport(Zone::Type zone, std::function<AbstractPropertyType* (void)> typeFactory, std::string sourceUuid="");
149 
150  template <class T>
151  std::shared_ptr<AbstractPropertyType> addPropertySupport(Zone::Type zone)
152  {
153  auto typeFactory = [](){
154  return new T;
155  };
156  return addPropertySupport(zone, typeFactory);
157  }
158 
159  //
160  // data:
161  //
162 
166  AbstractSource& source;
167 
173 
177  typedef std::map< Zone::Type, std::shared_ptr<AbstractPropertyType> > ZonePropertyType;
178 
183  std::map< VehicleProperty::Property, ZonePropertyType > properties;
184 
188  std::map< std::string, std::string> configuration;
189 };
190 
191 #endif // _AMBPLUGINIMPL_H_
192