A lot of updates for 1.4.12
This commit is contained in:
parent
607ae9a3e6
commit
e0eb4c5a16
@ -1,7 +1,6 @@
|
||||
#include <utility>
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <utility>
|
||||
#include "misc/memtracker.h"
|
||||
#include <ThreadPool/Mutex.h>
|
||||
#include "Variable.h"
|
||||
@ -21,6 +20,8 @@
|
||||
#define EXTERNALIZE_PROPERTY_DEFINITIONS
|
||||
#endif
|
||||
|
||||
#define PROPERTIES_DEFINED
|
||||
|
||||
namespace ts {
|
||||
namespace property {
|
||||
enum PropertyType {
|
||||
@ -527,7 +528,8 @@ namespace ts {
|
||||
return this->property_index == (int) other && this->type_property == type_from_enum<PropertyEnumType>();
|
||||
}
|
||||
|
||||
inline bool validate_input(const std::string& value) const { return impl::validateInput(value, this->type_value); }
|
||||
[[nodiscard]] inline bool is_undefined() const { return property_index == 0; }
|
||||
[[nodiscard]] inline bool validate_input(const std::string& value) const { return impl::validateInput(value, this->type_value); }
|
||||
};
|
||||
constexpr static PropertyDescription undefined_property_description{UnknownProperties::UNKNOWN_UNDEFINED, "undefined", "", ValueType::TYPE_UNKNOWN, 0};
|
||||
|
||||
@ -576,7 +578,7 @@ namespace ts {
|
||||
size_t index{begin};
|
||||
for(; index < property_list.size() - 1; index++)
|
||||
if(property_list[index + 1].type_property != type)
|
||||
return index;
|
||||
return index + 1;
|
||||
return property_list.size();
|
||||
}
|
||||
|
||||
@ -657,6 +659,16 @@ namespace ts {
|
||||
return find(type_from_enum<PropertyEnumType>(), name);
|
||||
}
|
||||
|
||||
template <typename PropertyEnumType, typename std::enable_if<std::is_enum<PropertyEnumType>::value, int>::type = 0>
|
||||
inline std::vector<const PropertyDescription*> list() {
|
||||
constexpr auto type = type_from_enum<PropertyEnumType>();
|
||||
if(type >= property_list_info.end_index.size()) return {};
|
||||
|
||||
const auto begin = property_list_info.begin_index[type];
|
||||
const auto end = property_list_info.end_index[type];
|
||||
return {property_list.begin() + begin, property_list.begin() + end};
|
||||
}
|
||||
|
||||
template <typename PropertyEnumType, typename std::enable_if<std::is_enum<PropertyEnumType>::value, int>::type = 0>
|
||||
const_modifier inline const std::string_view& name(PropertyEnumType type) { /* defining the return type here to help out my IDE a bit ;) */
|
||||
return describe<PropertyEnumType>(type).name;
|
||||
@ -690,7 +702,6 @@ namespace ts {
|
||||
struct PropertyBundle {
|
||||
property::PropertyType type;
|
||||
size_t length;
|
||||
size_t offset;
|
||||
PropertyData properties[0];
|
||||
};
|
||||
#ifdef WIN32
|
||||
|
@ -129,6 +129,7 @@ DEFINE_VARIABLE_TRANSFORM_TYPE(type, ntype)
|
||||
DEFINE_VARIABLE_TRANSFORM(class, VARTYPE_INT, std::to_string((size_type) in), static_cast<class>(in.as<size_type>()));
|
||||
|
||||
DEFINE_VARIABLE_TRANSFORM(std::string, VARTYPE_TEXT, in, in.value());
|
||||
DEFINE_VARIABLE_TRANSFORM(std::string_view, VARTYPE_TEXT, std::string{in}, std::string_view{in});
|
||||
DEFINE_VARIABLE_TRANSFORM(char*, VARTYPE_TEXT, std::string((const char*) in), (char*) in.value().c_str());
|
||||
DEFINE_VARIABLE_TRANSFORM(const char*, VARTYPE_TEXT, std::string((const char*) in), in.value().c_str());
|
||||
|
||||
|
@ -145,6 +145,6 @@ void AcknowledgeManager::update_rto(size_t r) {
|
||||
} else {
|
||||
this->rttvar = (1.f - alpha) * this->rttvar + beta * abs(this->srtt - r);
|
||||
this->srtt = (1.f - alpha) * srtt + alpha * r;
|
||||
this->rto = std::min(200.f, this->srtt + 4 * this->rttvar);
|
||||
this->rto = std::max(200.f, this->srtt + 4 * this->rttvar);
|
||||
}
|
||||
}
|
@ -185,6 +185,13 @@ namespace ts {
|
||||
this->put(key, std::string_view{data});
|
||||
}
|
||||
|
||||
#ifdef PROPERTIES_DEFINED
|
||||
template <typename PropertyType, typename T, std::enable_if_t<std::is_enum<PropertyType>::value, int> = 0>
|
||||
inline void put(PropertyType key, const T& value) {
|
||||
this->put(property::name(key), value);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* directly puts data without checking for duplicates */
|
||||
inline void put_unchecked(const std::string_view& key, const std::string_view& value) {
|
||||
this->impl_put_unchecked(key, value);
|
||||
@ -194,6 +201,13 @@ namespace ts {
|
||||
this->put_unchecked(key, std::string_view{value});
|
||||
}
|
||||
|
||||
#ifdef PROPERTIES_DEFINED
|
||||
template <typename PropertyType, typename T, std::enable_if_t<std::is_enum<PropertyType>::value, int> = 0>
|
||||
inline void put_unchecked(PropertyType key, const T& value) {
|
||||
this->put_unchecked(property::name(key), value);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <typename T, std::enable_if_t<!(std::is_same<T, std::string_view>::value || std::is_same<T, std::string>::value), int> = 1>
|
||||
inline void put_unchecked(const std::string_view& key, const T& value) {
|
||||
static_assert(converter<T>::supported, "Target type isn't supported!");
|
||||
@ -266,14 +280,14 @@ namespace ts {
|
||||
return command_builder_bulk{this->flag_changed, this->bulks[index]};
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void put(size_t index, const std::string_view& key, const T& value) {
|
||||
template <typename KeyT, typename ValueT>
|
||||
inline void put(size_t index, const KeyT& key, const ValueT& value) {
|
||||
this->bulk(index).put(key, value);
|
||||
}
|
||||
|
||||
/* directly puts data without checking for duplicates */
|
||||
template <typename T>
|
||||
inline void put_unchecked(size_t index, const std::string_view& key, const T& value) {
|
||||
template <typename KeyT, typename ValueT>
|
||||
inline void put_unchecked(size_t index, const KeyT& key, const ValueT& value) {
|
||||
this->bulk(index).put_unchecked(key, value);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user