XJ music engine  1.9.6
In-game runtime engine for XJ music.
Public Member Functions | Static Public Member Functions | List of all members
XJ::EntityUtils Class Reference

#include <EntityUtils.h>

Public Member Functions

virtual ~EntityUtils ()=default
 

Static Public Member Functions

template<typename A , typename B >
static std::map< B, AreverseMap (const std::map< A, B > &originalMap)
 
static long long currentTimeMillis ()
 
static std::string computeUniqueId ()
 
static void setRequired (const json &json, const std::string &key, UUID &value)
 
static void setIfNotNull (const json &json, const std::string &key, std::string &value)
 
static void setIfNotNull (const json &json, const std::string &key, float &value)
 
static void setIfNotNull (const json &json, const std::string &key, bool &value)
 
static void setIfNotNull (const json &json, const std::string &key, int &value)
 
static void setIfNotNull (const json &json, const std::string &key, long long &value)
 

Detailed Description

Base class for all models

Constructor & Destructor Documentation

◆ ~EntityUtils()

virtual XJ::EntityUtils::~EntityUtils ( )
virtualdefault

Default constructor

Member Function Documentation

◆ computeUniqueId()

std::string EntityUtils::computeUniqueId ( )
static

XJ legacy application used UUIDs because networked data was a possibility. But since the domain of this application is now entirely local, we do not require globally-unique randomness. Instead, we use a simple counter, which provides guaranteed locally unique identifiers

In the future, all entity IDs should be simple integers– but that's a massive refactoring job See: https://github.com/xjmusic/xjmusic/issues/400

Returns
locally unique identifier

◆ currentTimeMillis()

static long long XJ::EntityUtils::currentTimeMillis ( )
inlinestatic

Get the current time in milliseconds

Returns
The current time in milliseconds

◆ reverseMap()

template<typename A , typename B >
static std::map<B, A> XJ::EntityUtils::reverseMap ( const std::map< A, B > &  originalMap)
inlinestatic

Reverse a map

Template Parameters
Aoriginal key type -> value type
Boriginal value type -> key type
Parameters
originalMapThe original map
Returns
The reversed map

◆ setIfNotNull() [1/5]

void EntityUtils::setIfNotNull ( const json json,
const std::string &  key,
bool &  value 
)
static

Set an optional boolean field on an entity from a JSON object, if the value is not null

Parameters
jsonto source
keyto set
valueto set

◆ setIfNotNull() [2/5]

void EntityUtils::setIfNotNull ( const json json,
const std::string &  key,
float &  value 
)
static

Set an optional float on an entity from a JSON object, if the value is not null

Parameters
jsonto source
keyto set
valueto set

◆ setIfNotNull() [3/5]

void EntityUtils::setIfNotNull ( const json json,
const std::string &  key,
int &  value 
)
static

Set an optional integer field on an entity from a JSON object, if the value is not null

Parameters
jsonto source
keyto set
valueto set

◆ setIfNotNull() [4/5]

static void XJ::EntityUtils::setIfNotNull ( const json json,
const std::string &  key,
long long &  value 
)
static

Set an optional long integer field on an entity from a JSON object, if the value is not null

Parameters
jsonto source
keyto set
valueto set

◆ setIfNotNull() [5/5]

void EntityUtils::setIfNotNull ( const json json,
const std::string &  key,
std::string &  value 
)
static

Set an optional string field on an entity from a JSON object, if the value is not null

Parameters
jsonto source
keyto set
valueto set

◆ setRequired()

void EntityUtils::setRequired ( const json json,
const std::string &  key,
UUID value 
)
static

Set a required field on an entity from a JSON object

Parameters
jsonto source
keyto set
valueto set

The documentation for this class was generated from the following files: