ADTF
pin_creation.h
Go to the documentation of this file.
1 
7 #pragma once
8 #include "pin.h"
9 #include "samplewriter.h"
10 #include "samplereader.h"
11 
12 #include <type_traits>
13 
14 namespace adtf
15 {
16 namespace streaming
17 {
18 namespace ant
19 {
20 
36 template<typename DATA_BINDING_IMPL_TYPE>
37 tResult create_pin(DATA_BINDING_IMPL_TYPE& oDataBindingImpl,
38  cSampleWriter& oWriter,
39  const char* strNameOfWriterAndPin,
40  const ucom::iobject_ptr<const IStreamType>& pStreamType,
41  ucom::iobject_ptr<IOutPin>& pPinCreated)
42 {
43  oWriter.SetName(strNameOfWriterAndPin);
44  oWriter.SetType(pStreamType);
45 
46  adtf::ucom::object_ptr<cOutPin> pOutPin = adtf::ucom::make_object_ptr<cOutPin>(strNameOfWriterAndPin);
47  oWriter.ResetPin(pOutPin);
48  adtf::ucom::object_ptr<IPin> pPin = pOutPin;
49  RETURN_IF_FAILED(oDataBindingImpl.RegisterPin(pPin));
50  pPinCreated.Reset(adtf::ucom::ucom_object_ptr_cast<IOutPin>(pPin));
52 }
53 
68 template<typename DATA_BINDING_IMPL_TYPE>
69 tResult create_pin(DATA_BINDING_IMPL_TYPE& oDataBindingImpl,
70  cSampleWriter& oWriter,
71  const char* strNameOfWriterAndPin,
73 {
75  return create_pin(oDataBindingImpl, oWriter, strNameOfWriterAndPin, pStreamType, pPinCreated);
76 }
77 
92 template<typename DATA_BINDING_IMPL_TYPE>
93 tResult create_pin(DATA_BINDING_IMPL_TYPE& oDataBindingImpl,
94  cSampleWriter& oWriter,
95  const char* strNameOfWriterAndPin,
96  const adtf::ucom::iobject_ptr<IStreamType>& pStreamType)
97 {
98  return create_pin(oDataBindingImpl, oWriter, strNameOfWriterAndPin, adtf::ucom::ucom_object_ptr_cast<const IStreamType>(pStreamType));
99 }
100 
112 template<typename DATA_BINDING_IMPL_TYPE>
113 tResult create_pin(DATA_BINDING_IMPL_TYPE& oDataBindingImpl,
114  cSampleReader& oReader,
115  const char* strNameOfReaderAndPin,
116  const ucom::iobject_ptr<const IStreamType>& pStreamType,
117  ucom::iobject_ptr<IInPin>& pPinCreated)
118 {
119  oReader.SetName(strNameOfReaderAndPin);
120  oReader.SetType(pStreamType);
121 
122  adtf::ucom::object_ptr<cInPin> pInPin = adtf::ucom::make_object_ptr<cInPin>(strNameOfReaderAndPin);
123  oReader.ResetPin(pInPin);
124  adtf::ucom::object_ptr<IPin> pPin = pInPin;
125  RETURN_IF_FAILED(oDataBindingImpl.RegisterPin(pPin));
126  pPinCreated.Reset(adtf::ucom::ucom_object_ptr_cast<IInPin>(pPin));
128 }
129 
140 template<typename DATA_BINDING_IMPL_TYPE>
141 tResult create_pin(DATA_BINDING_IMPL_TYPE& oDataBindingImpl,
142  cSampleReader& oReader,
143  const char* strNameOfReaderAndPin,
144  const ucom::iobject_ptr<const IStreamType>& pStreamType)
145 {
146  adtf::ucom::object_ptr<IInPin> pPinCreated;
147  return create_pin(oDataBindingImpl, oReader, strNameOfReaderAndPin, pStreamType, pPinCreated);
148 }
149 
150 
161 template<typename DATA_BINDING_IMPL_TYPE>
162 tResult create_pin(DATA_BINDING_IMPL_TYPE& oDataBindingImpl,
163  cSampleReader& oReader,
164  const char* strNameOfReaderAndPin,
165  const adtf::ucom::iobject_ptr<IStreamType>& pStreamType)
166 {
167  return create_pin(oDataBindingImpl, oReader, strNameOfReaderAndPin, adtf::ucom::ucom_object_ptr_cast<const IStreamType>(pStreamType));
168 }
169 } //namespace ant
170 
171 namespace flash
172 {
173 
174 template<typename DATA_BINDING_IMPL_TYPE, typename READER_OR_WRITER, typename PIN_INTERFACE>
175 tResult create_pin(DATA_BINDING_IMPL_TYPE& oDataBindingImpl,
176  READER_OR_WRITER& oStreamer,
178 {
179  typedef typename std::conditional<std::is_base_of<flash::ISampleReader, READER_OR_WRITER>::value, quiet::cInPin, quiet::cOutPin>::type pin_type;
180  adtf::util::cString strNameOfReaderAndPin;
181  oStreamer.GetName(adtf_string_intf(strNameOfReaderAndPin));
182 
183  auto pInPin = adtf::ucom::make_object_ptr<pin_type>(strNameOfReaderAndPin);
184  oStreamer.SetStreamerPin(ucom::ant::ucom_object_ptr_cast<flash::IStreamerPin>(pInPin));
185  adtf::ucom::object_ptr<IPin> pPin = pInPin;
186  RETURN_IF_FAILED(oDataBindingImpl.RegisterPin(pPin));
187  return pCreatedPin.Reset(ucom::ant::ucom_object_ptr_cast<PIN_INTERFACE>(pPin));
188 }
189 
190 template<typename DATA_BINDING_IMPL_TYPE, typename READER_OR_WRITER>
191 tResult create_pin(DATA_BINDING_IMPL_TYPE& oDataBindingImpl,
192  READER_OR_WRITER& oStreamer)
193 {
194  typedef typename std::conditional<std::is_base_of<flash::ISampleReader, READER_OR_WRITER>::value, quiet::cInPin, quiet::cOutPin>::type pin_type;
195  adtf::util::cString strNameOfReaderAndPin;
196  oStreamer.GetName(adtf_string_intf(strNameOfReaderAndPin));
197 
198  auto pInPin = adtf::ucom::make_object_ptr<pin_type>(strNameOfReaderAndPin);
199  oStreamer.SetStreamerPin(ucom::ant::ucom_object_ptr_cast<flash::IStreamerPin>(pInPin));
200  adtf::ucom::object_ptr<IPin> pPin = pInPin;
201  return oDataBindingImpl.RegisterPin(pPin);
202 }
203 
204 template<typename DATA_BINDING_IMPL_TYPE, typename READER_OR_WRITER, typename PIN_INTERFACE>
205 tResult create_pin(DATA_BINDING_IMPL_TYPE& oDataBindingImpl,
206  READER_OR_WRITER& oStreamer,
207  const char* strNameOfReaderAndPin,
208  const ucom::iobject_ptr<const ant::IStreamType>& pStreamType,
209  ucom::ant::iobject_ptr<PIN_INTERFACE>& pCreatedPin)
210 {
211  oStreamer.SetName(strNameOfReaderAndPin);
212  oStreamer.SetType(pStreamType);
213 
214  return create_pin(oDataBindingImpl, oStreamer, pCreatedPin);
215 }
216 
217 template<typename DATA_BINDING_IMPL_TYPE, typename READER_OR_WRITER>
218 tResult create_pin(DATA_BINDING_IMPL_TYPE& oDataBindingImpl,
219  READER_OR_WRITER& oStreamer,
220  const char* strNameOfReaderAndPin,
221  const ucom::ant::iobject_ptr<const ant::IStreamType>& pStreamType)
222 {
223  oStreamer.SetName(strNameOfReaderAndPin);
224  oStreamer.SetType(pStreamType);
225 
226  return create_pin(oDataBindingImpl, oStreamer);
227 }
228 
229 }
230 
231 using flash::create_pin;
232 
233 } //namespace streaming
234 } //namespace adtf
#define RETURN_IF_FAILED(s)
Return if expression is failed, which requires the calling function's return type to be tResult.
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
The default Sample Reader will read the incomung Stream of a IInPin.
Definition: samplereader.h:174
This base implementation of a sample writer is able to write to one Sample Stream which is connected ...
Definition: samplewriter.h:35
void SetName(const char *strName)
Sets the name of the streamer.
Definition: samplereader.h:84
tResult SetType(const ucom::ant::iobject_ptr< const IStreamType > &pStreamType)
Sets the StreamType of the streamer.
Definition: samplereader.h:140
void ResetPin(ucom::ant::object_ptr< PINTYPE > &pPin)
Resets the pin reference This is only internaly used.
Definition: samplereader.h:95
virtual tResult Reset(const iobject_ptr< T > &i_oOther)=0
Reset this object_ptr<> with the content of another iobject_ptr<>
Base object pointer to realize binary compatible reference counting in interface methods.
Object pointer implementation used for reference counting on objects of type IObject.
Definition: object_ptr.h:163
string_base< cStackString > cString
cString implementation for a stack string which works on stack if string is lower than A_UTILS_DEFAUL...
Definition: string.h:2784
tResult create_pin(DATA_BINDING_IMPL_TYPE &oDataBindingImpl, cSampleWriter &oWriter, const char *strNameOfWriterAndPin, const ucom::iobject_ptr< const IStreamType > &pStreamType, ucom::iobject_ptr< IOutPin > &pPinCreated)
Creates a cOutPin and registers it at the given oDataBindingImpl instance.
Definition: pin_creation.h:37
Namespace for entire ADTF SDK.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
#define adtf_string_intf(__string__)
The adtf_string_intf Macro helps to easily create a rvalue reference of a adtf::util::cString.
Definition: string_intf.h:371