mirror of
https://github.com/overte-org/overte.git
synced 2025-04-15 17:20:12 +02:00
Merge pull request #9910 from jherico/vs2017
Fix build problems on VS 2015 and VS 2017
This commit is contained in:
commit
3fe4d6e733
4 changed files with 69 additions and 44 deletions
|
@ -246,10 +246,13 @@ void DomainServerSettingsManager::setupConfigMap(const QStringList& argumentList
|
|||
_agentPermissions[editorKey]->set(NodePermissions::Permission::canAdjustLocks);
|
||||
}
|
||||
|
||||
QList<QHash<NodePermissionsKey, NodePermissionsPointer>> permissionsSets;
|
||||
permissionsSets << _standardAgentPermissions.get() << _agentPermissions.get();
|
||||
std::list<std::unordered_map<NodePermissionsKey, NodePermissionsPointer>> permissionsSets{
|
||||
_standardAgentPermissions.get(),
|
||||
_agentPermissions.get()
|
||||
};
|
||||
foreach (auto permissionsSet, permissionsSets) {
|
||||
foreach (NodePermissionsKey userKey, permissionsSet.keys()) {
|
||||
for (auto entry : permissionsSet) {
|
||||
const auto& userKey = entry.first;
|
||||
if (onlyEditorsAreRezzers) {
|
||||
if (permissionsSet[userKey]->can(NodePermissions::Permission::canAdjustLocks)) {
|
||||
permissionsSet[userKey]->set(NodePermissions::Permission::canRezPermanentEntities);
|
||||
|
@ -300,7 +303,6 @@ void DomainServerSettingsManager::setupConfigMap(const QStringList& argumentList
|
|||
}
|
||||
|
||||
QVariantMap& DomainServerSettingsManager::getDescriptorsMap() {
|
||||
|
||||
static const QString DESCRIPTORS{ "descriptors" };
|
||||
|
||||
auto& settingsMap = getSettingsMap();
|
||||
|
@ -1355,18 +1357,12 @@ QStringList DomainServerSettingsManager::getAllKnownGroupNames() {
|
|||
// extract all the group names from the group-permissions and group-forbiddens settings
|
||||
QSet<QString> result;
|
||||
|
||||
QHashIterator<NodePermissionsKey, NodePermissionsPointer> i(_groupPermissions.get());
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
NodePermissionsKey key = i.key();
|
||||
result += key.first;
|
||||
for (const auto& entry : _groupPermissions.get()) {
|
||||
result += entry.first.first;
|
||||
}
|
||||
|
||||
QHashIterator<NodePermissionsKey, NodePermissionsPointer> j(_groupForbiddens.get());
|
||||
while (j.hasNext()) {
|
||||
j.next();
|
||||
NodePermissionsKey key = j.key();
|
||||
result += key.first;
|
||||
for (const auto& entry : _groupForbiddens.get()) {
|
||||
result += entry.first.first;
|
||||
}
|
||||
|
||||
return result.toList();
|
||||
|
@ -1377,20 +1373,17 @@ bool DomainServerSettingsManager::setGroupID(const QString& groupName, const QUu
|
|||
_groupIDs[groupName.toLower()] = groupID;
|
||||
_groupNames[groupID] = groupName;
|
||||
|
||||
QHashIterator<NodePermissionsKey, NodePermissionsPointer> i(_groupPermissions.get());
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
NodePermissionsPointer perms = i.value();
|
||||
|
||||
for (const auto& entry : _groupPermissions.get()) {
|
||||
auto& perms = entry.second;
|
||||
if (perms->getID().toLower() == groupName.toLower() && !perms->isGroup()) {
|
||||
changed = true;
|
||||
perms->setGroupID(groupID);
|
||||
}
|
||||
}
|
||||
|
||||
QHashIterator<NodePermissionsKey, NodePermissionsPointer> j(_groupForbiddens.get());
|
||||
while (j.hasNext()) {
|
||||
j.next();
|
||||
NodePermissionsPointer perms = j.value();
|
||||
for (const auto& entry : _groupForbiddens.get()) {
|
||||
auto& perms = entry.second;
|
||||
if (perms->getID().toLower() == groupName.toLower() && !perms->isGroup()) {
|
||||
changed = true;
|
||||
perms->setGroupID(groupID);
|
||||
|
|
|
@ -13,18 +13,31 @@
|
|||
#define hifi_NodePermissions_h
|
||||
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <QString>
|
||||
#include <QMap>
|
||||
#include <QVariant>
|
||||
#include <QUuid>
|
||||
|
||||
#include <QHash>
|
||||
#include <utility>
|
||||
#include "GroupRank.h"
|
||||
|
||||
class NodePermissions;
|
||||
using NodePermissionsPointer = std::shared_ptr<NodePermissions>;
|
||||
using NodePermissionsKey = QPair<QString, QUuid>; // name, rankID
|
||||
using NodePermissionsKey = std::pair<QString, QUuid>; // name, rankID
|
||||
using NodePermissionsKeyList = QList<QPair<QString, QUuid>>;
|
||||
|
||||
namespace std {
|
||||
template<>
|
||||
struct hash<NodePermissionsKey> {
|
||||
size_t operator()(const NodePermissionsKey& key) const {
|
||||
size_t result = qHash(key.first);
|
||||
result <<= 32;
|
||||
result |= qHash(key.second);
|
||||
return result;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
class NodePermissions {
|
||||
public:
|
||||
|
@ -100,27 +113,40 @@ public:
|
|||
NodePermissionsMap() { }
|
||||
NodePermissionsPointer& operator[](const NodePermissionsKey& key) {
|
||||
NodePermissionsKey dataKey(key.first.toLower(), key.second);
|
||||
if (!_data.contains(dataKey)) {
|
||||
if (0 == _data.count(dataKey)) {
|
||||
_data[dataKey] = NodePermissionsPointer(new NodePermissions(key));
|
||||
}
|
||||
return _data[dataKey];
|
||||
}
|
||||
NodePermissionsPointer operator[](const NodePermissionsKey& key) const {
|
||||
return _data.value(NodePermissionsKey(key.first.toLower(), key.second));
|
||||
NodePermissionsPointer result;
|
||||
auto itr = _data.find(NodePermissionsKey(key.first.toLower(), key.second));
|
||||
if (_data.end() != itr) {
|
||||
result = itr->second;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
bool contains(const NodePermissionsKey& key) const {
|
||||
return _data.contains(NodePermissionsKey(key.first.toLower(), key.second));
|
||||
return 0 != _data.count(NodePermissionsKey(key.first.toLower(), key.second));
|
||||
}
|
||||
bool contains(const QString& keyFirst, QUuid keySecond) const {
|
||||
return _data.contains(NodePermissionsKey(keyFirst.toLower(), keySecond));
|
||||
bool contains(const QString& keyFirst, const QUuid& keySecond) const {
|
||||
return 0 != _data.count(NodePermissionsKey(keyFirst.toLower(), keySecond));
|
||||
}
|
||||
QList<NodePermissionsKey> keys() const { return _data.keys(); }
|
||||
QHash<NodePermissionsKey, NodePermissionsPointer> get() { return _data; }
|
||||
|
||||
QList<NodePermissionsKey> keys() const {
|
||||
QList<NodePermissionsKey> result;
|
||||
for (const auto& entry : _data) {
|
||||
result.push_back(entry.first);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
const std::unordered_map<NodePermissionsKey, NodePermissionsPointer>& get() { return _data; }
|
||||
void clear() { _data.clear(); }
|
||||
void remove(const NodePermissionsKey& key) { _data.remove(key); }
|
||||
void remove(const NodePermissionsKey& key) { _data.erase(key); }
|
||||
|
||||
private:
|
||||
QHash<NodePermissionsKey, NodePermissionsPointer> _data;
|
||||
std::unordered_map<NodePermissionsKey, NodePermissionsPointer> _data;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -15,6 +15,10 @@
|
|||
|
||||
using namespace udt;
|
||||
|
||||
PacketQueue::PacketQueue() {
|
||||
_channels.emplace_back(new std::list<PacketPointer>());
|
||||
}
|
||||
|
||||
MessageNumber PacketQueue::getNextMessageNumber() {
|
||||
static const MessageNumber MAX_MESSAGE_NUMBER = MessageNumber(1) << MESSAGE_NUMBER_SIZE;
|
||||
_currentMessageNumber = (_currentMessageNumber + 1) % MAX_MESSAGE_NUMBER;
|
||||
|
@ -24,7 +28,7 @@ MessageNumber PacketQueue::getNextMessageNumber() {
|
|||
bool PacketQueue::isEmpty() const {
|
||||
LockGuard locker(_packetsLock);
|
||||
// Only the main channel and it is empty
|
||||
return (_channels.size() == 1) && _channels.front().empty();
|
||||
return (_channels.size() == 1) && _channels.front()->empty();
|
||||
}
|
||||
|
||||
PacketQueue::PacketPointer PacketQueue::takePacket() {
|
||||
|
@ -34,19 +38,19 @@ PacketQueue::PacketPointer PacketQueue::takePacket() {
|
|||
}
|
||||
|
||||
// Find next non empty channel
|
||||
if (_channels[nextIndex()].empty()) {
|
||||
if (_channels[nextIndex()]->empty()) {
|
||||
nextIndex();
|
||||
}
|
||||
auto& channel = _channels[_currentIndex];
|
||||
Q_ASSERT(!channel.empty());
|
||||
Q_ASSERT(!channel->empty());
|
||||
|
||||
// Take front packet
|
||||
auto packet = std::move(channel.front());
|
||||
channel.pop_front();
|
||||
auto packet = std::move(channel->front());
|
||||
channel->pop_front();
|
||||
|
||||
// Remove now empty channel (Don't remove the main channel)
|
||||
if (channel.empty() && _currentIndex != 0) {
|
||||
channel.swap(_channels.back());
|
||||
if (channel->empty() && _currentIndex != 0) {
|
||||
channel->swap(*_channels.back());
|
||||
_channels.pop_back();
|
||||
--_currentIndex;
|
||||
}
|
||||
|
@ -61,7 +65,7 @@ unsigned int PacketQueue::nextIndex() {
|
|||
|
||||
void PacketQueue::queuePacket(PacketPointer packet) {
|
||||
LockGuard locker(_packetsLock);
|
||||
_channels.front().push_back(std::move(packet));
|
||||
_channels.front()->push_back(std::move(packet));
|
||||
}
|
||||
|
||||
void PacketQueue::queuePacketList(PacketListPointer packetList) {
|
||||
|
@ -70,5 +74,6 @@ void PacketQueue::queuePacketList(PacketListPointer packetList) {
|
|||
}
|
||||
|
||||
LockGuard locker(_packetsLock);
|
||||
_channels.push_back(std::move(packetList->_packets));
|
||||
_channels.emplace_back(new std::list<PacketPointer>());
|
||||
_channels.back()->swap(packetList->_packets);
|
||||
}
|
||||
|
|
|
@ -30,10 +30,11 @@ class PacketQueue {
|
|||
using LockGuard = std::lock_guard<Mutex>;
|
||||
using PacketPointer = std::unique_ptr<Packet>;
|
||||
using PacketListPointer = std::unique_ptr<PacketList>;
|
||||
using Channel = std::list<PacketPointer>;
|
||||
using Channel = std::unique_ptr<std::list<PacketPointer>>;
|
||||
using Channels = std::vector<Channel>;
|
||||
|
||||
public:
|
||||
PacketQueue();
|
||||
void queuePacket(PacketPointer packet);
|
||||
void queuePacketList(PacketListPointer packetList);
|
||||
|
||||
|
@ -49,7 +50,7 @@ private:
|
|||
MessageNumber _currentMessageNumber { 0 };
|
||||
|
||||
mutable Mutex _packetsLock; // Protects the packets to be sent.
|
||||
Channels _channels = Channels(1); // One channel per packet list + Main channel
|
||||
Channels _channels; // One channel per packet list + Main channel
|
||||
unsigned int _currentIndex { 0 };
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue