Description
Shows how to transmit and receive samples containing strings.
Prebuilt Binaries
Source Code
./examples/demo_adtfplugins/demo_string_handling/
Receiver
demo_string_receiving_filter.h
#pragma once
#ifndef ADTF_EXAMPLES_CID
#define ADTF_EXAMPLES_CID ".local.cid"
#endif
{
public:
"demo_string_receiving.filter" ADTF_EXAMPLES_CID,
"Demo String Receiving");
public:
cDemoStringReceiving();
~cDemoStringReceiving() override;
private:
};
A_UTILS_NS::cResult tResult
For backwards compatibility and to bring latest version into scope.
Definition result.h:736
#define ADTF_CLASS_ID_NAME(_class, _strcid, _strclabel)
Definition class_id.h:33
virtual tResult ProcessInput(base::flash::tNanoSeconds tmTrigger, streaming::flash::ISampleReader *pReader)
Definition samplestreamer_intf.h:188
ant::iobject_ptr< T > iobject_ptr
Alias always bringing the latest version of ant::iobject_ptr into scope.
Definition object_ptr_intf.h:437
demo_string_receiving_filter.cpp
#include "demo_string_receiving_filter.h"
using namespace adtf::util;
cDemoStringReceiving::cDemoStringReceiving()
{
SetDescription("Use this filter to receive samples with string content via input pin. It used the stream_meta_type_string.");
SetDescription("in_string", "Handles an incoming adtf/string type");
SetHelpLink("$(ADTF_DIR)/doc/html/page_demo_string_receiving.html");
}
cDemoStringReceiving::~cDemoStringReceiving() = default;
{
if (pReader == m_pReaderString)
{
}
}
#define LOG_INFO(...)
Logs an info message.
Definition log.h:388
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
Definition result.h:29
Definition sample_data.h:429
Generator template to create an instance of a ant::IStreamType class for penguin::stream_meta_type_st...
Definition streammetatypestring.h:277
Namespace for the ADTF Base SDK.
Definition adtf_base_type_traits.h:13
Namespace for the ADTF Filter SDK.
Definition configurable_runner.h:18
Namespace for the ADTF Streaming SDK.
Definition bindingproxyinport.h:14
Namespace for the ADTF uCOM SDK.
Definition adtf_system.h:324
Sender
demo_string_sending_filter.h
#pragma once
#ifndef ADTF_EXAMPLES_CID
#define ADTF_EXAMPLES_CID ".local.cid"
#endif
{
public:
"demo_string_sending.filter" ADTF_EXAMPLES_CID,
"Demo String Sending");
public:
cDemoStringSending();
~cDemoStringSending() override;
private:
};
virtual tResult Process(base::flash::tNanoSeconds tmTrigger, streaming::ant::IRunner *pRunner)
Definition runner_intf.h:24
Definition samplewriter.h:499
A timestamp with nanosecond precision.
Definition chrono.h:23
demo_string_sending_filter.cpp
#include "demo_string_sending_filter.h"
#include <codecvt>
#include <iostream>
#include <locale>
#include <sstream>
using namespace adtf::util;
cDemoStringSending::cDemoStringSending()
{
SetDescription("Use this filter to send samples with string content via output pin. It uses the stream_type_string.");
SetDescription("out_string", "Provides a string with the current time");
m_pWriterU16String
SetDescription("out_16string", "Provides a u16string with the current time");
CreateRunner("string_generator_function", cTimerTriggerHint(std::chrono::seconds {1}));
SetDescription("string_generator_function", "Runner to periodically trigger the function which generates the output data for all pins");
SetHelpLink("$(ADTF_DIR)/doc/html/page_demo_string_sending.html");
}
cDemoStringSending::~cDemoStringSending() = default;
namespace
{
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
std::u16string convert_to_u16string(const std::string& strValue)
{
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> oConverter;
return oConverter.from_bytes(strValue);
}
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
template<typename T>
std::u16string to_u16string(const T& value)
{
return convert_to_u16string(std::to_string(value));
}
}
{
{
std::stringstream strTimeToSend;
strTimeToSend << "Hello, current trigger time is : " << tmTimeOfTrigger.nCount << " nanoseconds";
RETURN_IF_FAILED(m_pWriterString->Write(tmTimeOfTrigger, strTimeToSend.str()));
}
{
std::u16string strTimeToSend = u"Hello, current trigger time is : " + to_u16string(tmTimeOfTrigger.nCount) + u" nanoseconds"
+ u" with umlauts :" + u"\u00e4" + u" " + u"\u00f6" + u" " + u"\u00fc";
RETURN_IF_FAILED(m_pWriterU16String->Write(tmTimeOfTrigger, strTimeToSend));
}
}
Plugin
plugin.cpp
#include "demo_string_sending_filter.h"
#include "demo_string_receiving_filter.h"
cDemoStringSending,
cDemoStringReceiving);
#define ADTF_PLUGIN(__plugin_identifier,...)
Definition adtf_plugin.h:29