Fixed some compile errors

This commit is contained in:
WolverinDEV 2021-03-01 14:50:57 +01:00
parent 206e0052d1
commit 26981b95f7
2 changed files with 32 additions and 15 deletions

View File

@ -13,9 +13,12 @@ using namespace std::chrono;
using namespace ts; using namespace ts;
BasicChannel::BasicChannel(ChannelId parentId, ChannelId channelId) { BasicChannel::BasicChannel(ChannelId parentId, ChannelId channelId) {
this->setProperties(make_shared<PropertyManager>()); {
auto properties = std::make_shared<PropertyManager>();
properties->register_property_type<property::ChannelProperties>();
this->setProperties(properties);
}
this->_properties->register_property_type<property::ChannelProperties>();
this->properties()[property::CHANNEL_ID] = channelId; this->properties()[property::CHANNEL_ID] = channelId;
this->properties()[property::CHANNEL_PID] = parentId; this->properties()[property::CHANNEL_PID] = parentId;
} }
@ -35,17 +38,17 @@ void BasicChannel::setProperties(const std::shared_ptr<ts::PropertyManager>& pro
this->_properties = props; this->_properties = props;
this->properties()->registerNotifyHandler([&](Property& prop){ this->properties()->registerNotifyHandler([&](Property& prop){
if(prop.type() == property::CHANNEL_FLAG_DEFAULT) if(prop.type() == property::CHANNEL_FLAG_DEFAULT) {
this->properties()[property::CHANNEL_FLAG_PASSWORD] = false; this->properties()[property::CHANNEL_FLAG_PASSWORD] = false;
else if(prop.type() == property::CHANNEL_ID) } else if(prop.type() == property::CHANNEL_ID) {
this->_channel_id = prop; this->_channel_id = prop;
else if(prop.type() == property::CHANNEL_ORDER) } else if(prop.type() == property::CHANNEL_ORDER) {
this->_channel_order = prop; this->_channel_order = prop;
}
}); });
//Update cached variables //Update cached variables
if(props->has(property::CHANNEL_ORDER)) this->_channel_order = this->properties()[property::CHANNEL_ORDER]; this->_channel_order = this->properties()[property::CHANNEL_ORDER];
else this->_channel_order = 0;
this->_channel_id = this->channelId(); this->_channel_id = this->channelId();
} }
@ -108,9 +111,13 @@ BasicChannel::BasicChannel(std::shared_ptr<BasicChannel> parent, ChannelId chann
BasicChannel::~BasicChannel() { } BasicChannel::~BasicChannel() { }
ChannelType::ChannelType BasicChannel::channelType() { ChannelType::ChannelType BasicChannel::channelType() {
if (this->properties()[property::CHANNEL_FLAG_PERMANENT].as_unchecked<bool>()) return ChannelType::ChannelType::permanent; if(this->properties()[property::CHANNEL_FLAG_PERMANENT].as_or<bool>(true)) {
else if (this->properties()[property::CHANNEL_FLAG_SEMI_PERMANENT].as_unchecked<bool>()) return ChannelType::ChannelType::semipermanent; return ChannelType::ChannelType::permanent;
else return ChannelType::ChannelType::temporary; } else if (this->properties()[property::CHANNEL_FLAG_SEMI_PERMANENT].as_or<bool>(false)) {
return ChannelType::ChannelType::semipermanent;
} else {
return ChannelType::ChannelType::temporary;
}
} }
void BasicChannel::setChannelType(ChannelType::ChannelType type) { void BasicChannel::setChannelType(ChannelType::ChannelType type) {
@ -269,16 +276,24 @@ deque<std::shared_ptr<ts::BasicChannel>> BasicChannelTree::delete_channel_root(c
} }
bool BasicChannelTree::setDefaultChannel(const shared_ptr<BasicChannel> &ch) { bool BasicChannelTree::setDefaultChannel(const shared_ptr<BasicChannel> &ch) {
if (!ch) return false; if (!ch) {
for (const auto &elm : this->channels()) return false;
elm->properties()[property::CHANNEL_FLAG_DEFAULT] = false; }
for (const auto &elm : this->channels()) {
elm->properties()[property::CHANNEL_FLAG_DEFAULT].update_value(false);
}
ch->properties()[property::CHANNEL_FLAG_DEFAULT] = true; ch->properties()[property::CHANNEL_FLAG_DEFAULT] = true;
return true; return true;
} }
std::shared_ptr<BasicChannel> BasicChannelTree::getDefaultChannel() { std::shared_ptr<BasicChannel> BasicChannelTree::getDefaultChannel() {
for (auto elm : this->channels()) for (auto elm : this->channels()) {
if (elm->properties()[property::CHANNEL_FLAG_DEFAULT].as_unchecked<bool>()) return elm; if (elm->properties()[property::CHANNEL_FLAG_DEFAULT].as_or<bool>(false)) {
return elm;
}
}
return nullptr; return nullptr;
} }

View File

@ -104,9 +104,11 @@ void PropertyManager::do_register_property_type(ts::property::PropertyType type,
property.casted_value.~any(); property.casted_value.~any();
} }
bundle->value_mutex.~mutex();
::free(bundle); ::free(bundle);
}); });
new (&ptr->value_mutex) std::mutex{};
ptr->type = type; ptr->type = type;
ptr->property_count = length; ptr->property_count = length;