mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 09:48:44 +02:00
Cleaning the feature not conditional do the true design
This commit is contained in:
parent
543f322ffe
commit
c2687b4998
4 changed files with 31 additions and 20 deletions
|
@ -26,6 +26,7 @@
|
||||||
#include "Logging.h"
|
#include "Logging.h"
|
||||||
|
|
||||||
#include "impl/conditionals/AndConditional.h"
|
#include "impl/conditionals/AndConditional.h"
|
||||||
|
#include "impl/conditionals/NotConditional.h"
|
||||||
#include "impl/conditionals/EndpointConditional.h"
|
#include "impl/conditionals/EndpointConditional.h"
|
||||||
#include "impl/conditionals/ScriptConditional.h"
|
#include "impl/conditionals/ScriptConditional.h"
|
||||||
|
|
||||||
|
@ -838,18 +839,16 @@ Conditional::Pointer UserInputMapper::parseConditional(const QJsonValue& value)
|
||||||
|
|
||||||
auto input = findDeviceInput(conditionalToken);
|
auto input = findDeviceInput(conditionalToken);
|
||||||
auto endpoint = endpointFor(input);
|
auto endpoint = endpointFor(input);
|
||||||
if (!endpoint) {
|
auto conditional = std::make_shared<EndpointConditional>(endpoint);
|
||||||
return Conditional::Pointer();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!conditionalModifier.isEmpty()) {
|
if (!conditionalModifier.isEmpty()) {
|
||||||
if (conditionalModifier == JSON_CONDITIONAL_MODIFIER_NOT) {
|
if (conditionalModifier == JSON_CONDITIONAL_MODIFIER_NOT) {
|
||||||
return std::make_shared<NotEndpointConditional>(endpoint);
|
return std::make_shared<NotConditional>(conditional);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default and conditional behavior
|
// Default and conditional behavior
|
||||||
return std::make_shared<EndpointConditional>(endpoint);
|
return conditional;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Conditional::parse(value);
|
return Conditional::parse(value);
|
||||||
|
|
|
@ -23,13 +23,5 @@ private:
|
||||||
Endpoint::Pointer _endpoint;
|
Endpoint::Pointer _endpoint;
|
||||||
};
|
};
|
||||||
|
|
||||||
class NotEndpointConditional : public Conditional {
|
|
||||||
public:
|
|
||||||
NotEndpointConditional(Endpoint::Pointer endpoint) : _endpoint(endpoint) {}
|
|
||||||
virtual bool satisfied() override { return _endpoint && _endpoint->value() == 0.0; }
|
|
||||||
private:
|
|
||||||
Endpoint::Pointer _endpoint;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -6,10 +6,16 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
// NOTE: we don't need to include this header unless/until we add additional symbols.
|
|
||||||
// By removing this header we prevent these warnings on windows:
|
#include "NotConditional.h"
|
||||||
//
|
|
||||||
// warning LNK4221: This object file does not define any previously undefined public symbols,
|
using namespace controller;
|
||||||
// so it will not be used by any link operation that consumes this library
|
|
||||||
//
|
bool NotConditional::satisfied() {
|
||||||
//#include "NotConditional.h"
|
if (_operand) {
|
||||||
|
return (!_operand->satisfied());
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,5 +12,19 @@
|
||||||
|
|
||||||
#include "../Conditional.h"
|
#include "../Conditional.h"
|
||||||
|
|
||||||
|
namespace controller {
|
||||||
|
|
||||||
|
class NotConditional : public Conditional {
|
||||||
|
public:
|
||||||
|
using Pointer = std::shared_ptr<NotConditional>;
|
||||||
|
|
||||||
|
NotConditional(Conditional::Pointer operand) : _operand(operand) { }
|
||||||
|
|
||||||
|
virtual bool satisfied() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Conditional::Pointer _operand;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue