3 * Copyright (C) 2012-2013 Team XBMC
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
11 * This Program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with XBMC; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
25 #include <boost/shared_ptr.hpp>
27 #include "utils/IXmlDeserializable.h"
30 BooleanLogicOperationOr = 0,
31 BooleanLogicOperationAnd
32 } BooleanLogicOperation;
34 class CBooleanLogicValue : public IXmlDeserializable
37 CBooleanLogicValue(const std::string &value = "", bool negated = false)
38 : m_value(value), m_negated(negated)
40 virtual ~CBooleanLogicValue() { }
42 virtual bool Deserialize(const TiXmlNode *node);
44 virtual const std::string& GetValue() const { return m_value; }
45 virtual bool IsNegated() const { return m_negated; }
46 virtual const char* GetTag() const { return "value"; }
48 virtual void SetValue(const std::string &value) { m_value = value; }
49 virtual void SetNegated(bool negated) { m_negated = negated; }
56 typedef boost::shared_ptr<CBooleanLogicValue> CBooleanLogicValuePtr;
57 typedef std::vector<CBooleanLogicValuePtr> CBooleanLogicValues;
59 class CBooleanLogicOperation;
60 typedef boost::shared_ptr<CBooleanLogicOperation> CBooleanLogicOperationPtr;
61 typedef std::vector<CBooleanLogicOperationPtr> CBooleanLogicOperations;
63 class CBooleanLogicOperation : public IXmlDeserializable
66 CBooleanLogicOperation(BooleanLogicOperation op = BooleanLogicOperationAnd)
69 virtual ~CBooleanLogicOperation();
71 virtual bool Deserialize(const TiXmlNode *node);
73 virtual BooleanLogicOperation GetOperation() const { return m_operation; }
74 virtual const CBooleanLogicOperations& GetOperations() const { return m_operations; }
75 virtual const CBooleanLogicValues& GetValues() const { return m_values; }
77 virtual void SetOperation(BooleanLogicOperation op) { m_operation = op; }
80 virtual CBooleanLogicOperation* newOperation() { return new CBooleanLogicOperation(); }
81 virtual CBooleanLogicValue* newValue() { return new CBooleanLogicValue(); }
83 BooleanLogicOperation m_operation;
84 CBooleanLogicOperations m_operations;
85 CBooleanLogicValues m_values;
88 class CBooleanLogic : public IXmlDeserializable
92 virtual ~CBooleanLogic() { }
94 virtual bool Deserialize(const TiXmlNode *node);
96 virtual const CBooleanLogicOperationPtr& Get() const { return m_operation; }
97 virtual CBooleanLogicOperationPtr Get() { return m_operation; }
100 CBooleanLogicOperationPtr m_operation;