summaryrefslogtreecommitdiffstats
path: root/ahl-binding/role.cpp
blob: 9338436afa55d82c92ce81e14e731e06a4ad6464 (plain)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*
 * Copyright (C) 2018 "IoT.bzh"
 * Author Loïc Collignon <loic.collignon@iot.bzh>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "role.hpp"
#include "jsonc_utils.hpp"

role_t::role_t(std::string uid, std::string name, std::string description, std::string stream, int priority)
    : uid_{uid}
    , name_{name}
    , description_{description}
    , stream_{stream}
    , priority_{priority}
{
}

role_t::role_t(json_object* j)
{
    jcast(uid_, j, "uid");
    jcast(name_, j, "name");
    jcast(description_, j, "description");
    jcast(priority_, j, "priority");
    jcast(stream_, j, "stream");
    jcast_array(interrupts_, j, "interrupts");
}

role_t& role_t::operator<<(json_object* j)
{
    jcast(uid_, j, "uid");
    jcast(name_, j, "name");
    jcast(description_, j, "description");
    jcast(priority_, j, "priority");
    jcast(stream_, j, "stream");
    jcast_array(interrupts_, j, "interrupts");
    return *this;
}

std::string role_t::uid() const
{
    return uid_;
}

std::string role_t::name() const
{
    return name_;
}

std::string role_t::description() const
{
    return description_;
}

std::string role_t::stream() const
{
    return stream_;
}

int role_t::priority() const
{
    return priority_;
}

std::string role_t::device_uri() const
{
    return device_uri_;
}

void role_t::uid(std::string v)
{
    uid_ = v;
}

void role_t::name(std::string v)
{
    name_ = v;
}

void role_t::description(std::string v)
{
    description_ = v;
}

void role_t::stream(std::string v)
{
    stream_ = v;
}

void role_t::priority(int v)
{
    priority_ = v;
}

void role_t::device_uri(std::string v)
{
    device_uri_ = v;
}

const std::vector<interrupt_t>& role_t::interrupts() const
{
    return interrupts_;
}