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

View File

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