-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathI2CHelpers.h
42 lines (32 loc) · 961 Bytes
/
I2CHelpers.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
* (c)2017 CDP Technologies AS
*/
#ifndef I2CHELPERS_H
#define I2CHELPERS_H
#include <StudioAPI/NodeStream.h>
#include <CDPSystem/Base/CDPProperty.h>
#include <CDPDefines.h>
#include <string>
template <typename T>
static const char* c_str(const T& t)
{
return static_cast<const std::string&>(t).c_str();
}
template <typename ... T>
static void MessageLine(const std::string& format, const T& ... args)
{
CDPMessage((format + '\n').c_str(), args ...);
}
template <typename T>
static void ConfigureProperty(
CDPProperty<T>& property, const std::string& name,
CDPBaseObject* owner, XMLElementEx* element)
{
const std::string NameAttribute = "Name";
auto prefix = element->GetAttributeValue(NameAttribute);
property.Create(prefix.append(".").append(name).c_str(), owner);
property.Configure(element->FindAttribute(name));
property.AddNodeModeFlags(CDP::StudioAPI::eValueIsReadOnly);
property.SetNodeReparented(true);
}
#endif