XJ music engine
1.9.6
In-game runtime engine for XJ music.
include
xjmusic
content
Program.h
Go to the documentation of this file.
1
// Copyright (c) XJ Music Inc. (https://xjmusic.com) All Rights Reserved.
2
3
#ifndef XJMUSIC_PROGRAM_H
4
#define XJMUSIC_PROGRAM_H
5
6
#include <string>
7
8
#include "
ContentEntity.h
"
9
#include "
ProgramConfig.h
"
10
#include "
xjmusic/util/EntityUtils.h
"
11
12
namespace
XJ
{
13
14
class
Program
:
public
ContentEntity
{
15
public
:
16
enum
Type
{
17
Macro
,
18
Main
,
19
Beat
,
20
Detail
21
};
22
23
enum
State
{
24
Draft
,
25
Published
26
};
27
28
Program
() =
default
;
29
30
UUID
libraryId
;
31
State
state
{};
32
Type
type
{};
33
std::string
key
;
34
float
tempo
{};
35
std::string
name
;
36
ProgramConfig
config
;
37
bool
isDeleted
{};
38
long
long
updatedAt
{
EntityUtils::currentTimeMillis
()};
39
45
static
Type
parseType
(
const
std::string &value);
46
52
static
State
parseState
(
const
std::string &value);
53
59
static
std::string
toString
(
const
Type
&
type
);
60
66
static
std::string
toString
(
const
State
&
state
);
67
};
68
74
inline
void
from_json
(
const
json
&
json
,
Program
&entity) {
75
EntityUtils::setRequired
(
json
,
"id"
, entity.
id
);
76
EntityUtils::setRequired
(
json
,
"libraryId"
, entity.
libraryId
);
77
entity.
state
=
Program::parseState
(
json
.at(
"state"
).get<std::string>());
78
entity.
type
=
Program::parseType
(
json
.at(
"type"
).get<std::string>());
79
EntityUtils::setIfNotNull
(
json
,
"key"
, entity.
key
);
80
EntityUtils::setIfNotNull
(
json
,
"tempo"
, entity.
tempo
);
81
EntityUtils::setIfNotNull
(
json
,
"name"
, entity.
name
);
82
EntityUtils::setIfNotNull
(
json
,
"isDeleted"
, entity.
isDeleted
);
83
EntityUtils::setIfNotNull
(
json
,
"updatedAt"
, entity.
updatedAt
);
84
85
if
(
json
.contains(
"config"
) &&
json
.at(
"config"
).is_string()) {
86
const
auto
configStr =
json
.at(
"config"
).get<std::string>();
87
entity.
config
=
ProgramConfig
(configStr);
88
}
89
}
90
91
}
// namespace XJ
92
93
#endif
//XJMUSIC_PROGRAM_H
ContentEntity.h
EntityUtils.h
json
nlohmann::json json
Definition:
EntityUtils.h:14
ProgramConfig.h
XJ::ContentEntity
Definition:
ContentEntity.h:12
XJ::ContentEntity::id
UUID id
Definition:
ContentEntity.h:17
XJ::EntityUtils::currentTimeMillis
static long long currentTimeMillis()
Definition:
EntityUtils.h:62
XJ::EntityUtils::setIfNotNull
static void setIfNotNull(const json &json, const std::string &key, std::string &value)
Definition:
EntityUtils.cpp:27
XJ::EntityUtils::setRequired
static void setRequired(const json &json, const std::string &key, UUID &value)
Definition:
EntityUtils.cpp:16
XJ::ProgramConfig
Definition:
ProgramConfig.h:11
XJ::Program
Definition:
Program.h:14
XJ::Program::type
Type type
Definition:
Program.h:32
XJ::Program::key
std::string key
Definition:
Program.h:33
XJ::Program::State
State
Definition:
Program.h:23
XJ::Program::Draft
@ Draft
Definition:
Program.h:24
XJ::Program::Published
@ Published
Definition:
Program.h:25
XJ::Program::parseType
static Type parseType(const std::string &value)
Definition:
Program.cpp:30
XJ::Program::libraryId
UUID libraryId
Definition:
Program.h:30
XJ::Program::Program
Program()=default
XJ::Program::tempo
float tempo
Definition:
Program.h:34
XJ::Program::isDeleted
bool isDeleted
Definition:
Program.h:37
XJ::Program::updatedAt
long long updatedAt
Definition:
Program.h:38
XJ::Program::config
ProgramConfig config
Definition:
Program.h:36
XJ::Program::name
std::string name
Definition:
Program.h:35
XJ::Program::parseState
static State parseState(const std::string &value)
Definition:
Program.cpp:38
XJ::Program::Type
Type
Definition:
Program.h:16
XJ::Program::Detail
@ Detail
Definition:
Program.h:20
XJ::Program::Beat
@ Beat
Definition:
Program.h:19
XJ::Program::Main
@ Main
Definition:
Program.h:18
XJ::Program::Macro
@ Macro
Definition:
Program.h:17
XJ::Program::toString
static std::string toString(const Type &type)
Definition:
Program.cpp:46
XJ::Program::state
State state
Definition:
Program.h:31
XJ
Definition:
ActiveAudio.h:11
XJ::UUID
std::string UUID
Definition:
EntityUtils.h:28
XJ::from_json
void from_json(const json &json, Instrument &entity)
Definition:
Instrument.h:106
Generated by
1.9.1