All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cpp_interface.event_class_cpp.ftl Maven / Gradle / Ivy

Go to download

Tool that generates code for RPC between the Kurento Media Server and remote libraries.

There is a newer version: 7.1.0
Show newest version
${event.name}.cpp
/* Autogenerated with kurento-module-creator */

#include "${event.name}.hpp"
#include 
<#list event.properties as property>
<#if module.remoteClasses?seq_contains(property.type.type) ||
  module.complexTypes?seq_contains(property.type.type) ||
  module.events?seq_contains(property.type.type)>
#include "${property.type.name}.hpp"


#include 
#include 
#include 

<#list module.code.implementation["cppNamespace"]?split("::") as namespace>
namespace ${namespace}
{

<#if event.name = "RaiseBase">
static
std::string getCurrentTime ()
{
  time_t timer;
  time(&timer);
  return std::to_string ((int)(timer));
}

static
std::string getCurrentTimeMillis ()
{
  const auto epoch = std::chrono::high_resolution_clock::now ()
      .time_since_epoch ();
  const auto millis = std::chrono::duration_cast
      (epoch).count ();
  return std::to_string (millis);
}

${event.name}::${event.name} (<#rt>
  <#lt><#assign first = true><#rt>
  <#lt><#list event.properties as property><#rt>
  <#lt><#if !property.name?starts_with("timestamp") && property.name != "tags"><#rt>
    <#lt><#if !property.optional><#rt>
      <#lt><#if !first>, <#rt>
      <#lt><#assign first = false><#rt>
      <#lt>${getCppObjectType(property.type)}${property.name}<#rt>
    <#lt><#rt>
  <#rt>
  <#lt><#rt>)
  {
  <#list event.properties as property><#rt>
    <#lt><#if !property.name?starts_with("timestamp") && property.name != "tags"><#rt>
      <#lt><#if !property.optional><#rt>
  this->${property.name} = ${property.name};
      <#rt>
    <#rt>
  <#lt>
  this->setTimestamp (getCurrentTime());
  this->setTimestampMillis (getCurrentTimeMillis ());
  if (source != nullptr) {
    if (source->getSendTagsInEvents ()) {
      this->setTags (source->getTags ());
    }
  }
}


void
${event.name}::Serialize (JsonSerializer &s)
{
<#if event.extends??>
  ${event.extends.name}::Serialize (s);


<#list event.properties as property>
  s.SerializeNVP (${property.name});

}

<#list module.code.implementation["cppNamespace"]?split("::")?reverse as namespace>
} /* ${namespace} */


namespace kurento
{

void Serialize (std::shared_ptr<${module.code.implementation["cppNamespace"]}::${event.name}> &event, JsonSerializer &s)
{
  if (!s.IsWriter && !event) {
    event.reset (new ${module.code.implementation["cppNamespace"]}::${event.name}() );
  }

  if (event) {
    event->Serialize (s);
  }
}

} /* kurento */




© 2015 - 2024 Weber Informatics LLC | Privacy Policy