automotive-message-broker  0.13
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Modules 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 
virtual int supportedOperations() const
supportedOperations
Definition: ambpluginimpl.cpp:112
AbstractRoutingEngine * routingEngine
Definition: ambpluginimpl.h:172
virtual AbstractPropertyType * findPropertyType(const VehicleProperty::Property &propertyName, const Zone::Type &zone=Zone::None)
Definition: ambpluginimpl.cpp:122
Definition: abstractpropertytype.h:70
AmbPluginImpl(AbstractRoutingEngine *re, const map< string, string > &config, AbstractSource &parent)
Definition: ambpluginimpl.cpp:28
Definition: abstractroutingengine.h:366
virtual void supportedChanged(const PropertyList &supportedProperties)
Definition: ambpluginimpl.cpp:184
virtual void unsubscribeToPropertyChanges(const VehicleProperty::Property &property)
unsubscribeToPropertyChanges is called when a sink requests to unsubscribe from a given property's ch...
Definition: ambpluginimpl.cpp:117
std::map< Zone::Type, std::shared_ptr< AbstractPropertyType > > ZonePropertyType
Definition: ambpluginimpl.h:177
virtual void getRangePropertyAsync(AsyncRangePropertyReply *reply)
getRangePropertyAsync is called when a sink requests a series of values for a given property within a...
Definition: ambpluginimpl.cpp:61
The AsyncPropertyReply class is used by sources to reply to Get and Set operations. The source should set success to true if the call is successful or 'false' if the request was not successful and set 'error' to the appropriate error.
Definition: abstractroutingengine.h:123
AmbPlugin private class implementation - base class for all plugin implementations.
Definition: ambpluginimpl.h:36
virtual PropertyInfo getPropertyInfo(const VehicleProperty::Property &property)
getPropertyInfo used to return specific information about a property. The source should override this...
Definition: ambpluginimpl.cpp:166
virtual void init()
Definition: ambpluginimpl.cpp:35
The AsyncSetPropertyRequest class is used by sinks to set a property to the 'value'. The source will reply with a AsyncPropertyReply containing the new value or an error.
Definition: abstractroutingengine.h:219
Definition: propertyinfo.hpp:6
virtual void subscribeToPropertyChanges(const VehicleProperty::Property &property)
subscribeToPropertyChanges is called when a sink requests a subscription. Source plugins can keep tra...
Definition: ambpluginimpl.cpp:99
The AsyncRangePropertyReply class is used by a source to reply to an AsyncRangePropertyRequest. The source should set success to 'true' and populate the 'values' member if the request was successful. If the request is not successful, 'success' should be set to 'false' and the 'error' member should be set.
Definition: abstractroutingengine.h:331
virtual void propertyChanged(AbstractPropertyType *value)
Definition: ambpluginimpl.cpp:180
std::map< VehicleProperty::Property, ZonePropertyType > properties
Definition: ambpluginimpl.h:183
virtual PropertyList supported() const
supported is called by the routingEngine to understand what properties this source supports...
Definition: ambpluginimpl.cpp:104
virtual const std::string uuid() const =0
std::shared_ptr< AbstractPropertyType > addPropertySupport(Zone::Type zone, std::function< AbstractPropertyType *(void)> typeFactory, std::string sourceUuid="")
Definition: ambpluginimpl.cpp:136
std::map< std::string, std::string > configuration
Definition: ambpluginimpl.h:188
Definition: abstractsource.h:41
virtual void getPropertyAsync(AsyncPropertyReply *reply)
getPropertyAsync is called when a sink requests the value for given property. This is only called if ...
Definition: ambpluginimpl.cpp:39
virtual AsyncPropertyReply * setProperty(const AsyncSetPropertyRequest &request)
setProperty is called when a sink requests to set a value for a given property. This is only called i...
Definition: ambpluginimpl.cpp:75