Merge pull request #4676 from jmarshallnz/dont_set_scraper_on_tvshow_on_nfo
[vuplus_xbmc] / xbmc / utils / BooleanLogic.h
1 #pragma once
2 /*
3  *      Copyright (C) 2012-2013 Team XBMC
4  *      http://xbmc.org
5  *
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)
9  *  any later version.
10  *
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.
15  *
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/>.
19  *
20  */
21
22 #include <string>
23 #include <vector>
24
25 #include <boost/shared_ptr.hpp>
26
27 #include "utils/IXmlDeserializable.h"
28
29 typedef enum {
30   BooleanLogicOperationOr = 0,
31   BooleanLogicOperationAnd
32 } BooleanLogicOperation;
33
34 class CBooleanLogicValue : public IXmlDeserializable
35 {
36 public:
37   CBooleanLogicValue(const std::string &value = "", bool negated = false)
38     : m_value(value), m_negated(negated)
39   { }
40   virtual ~CBooleanLogicValue() { }
41
42   virtual bool Deserialize(const TiXmlNode *node);
43
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"; }
47
48   virtual void SetValue(const std::string &value) { m_value = value; }
49   virtual void SetNegated(bool negated) { m_negated = negated; }
50
51 protected:
52   std::string m_value;
53   bool m_negated;
54 };
55
56 typedef boost::shared_ptr<CBooleanLogicValue> CBooleanLogicValuePtr;
57 typedef std::vector<CBooleanLogicValuePtr> CBooleanLogicValues;
58
59 class CBooleanLogicOperation;
60 typedef boost::shared_ptr<CBooleanLogicOperation> CBooleanLogicOperationPtr;
61 typedef std::vector<CBooleanLogicOperationPtr> CBooleanLogicOperations;
62
63 class CBooleanLogicOperation : public IXmlDeserializable
64 {
65 public:
66   CBooleanLogicOperation(BooleanLogicOperation op = BooleanLogicOperationAnd)
67     : m_operation(op)
68   { }
69   virtual ~CBooleanLogicOperation();
70
71   virtual bool Deserialize(const TiXmlNode *node);
72
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; }
76
77   virtual void SetOperation(BooleanLogicOperation op) { m_operation = op; }
78
79 protected:
80   virtual CBooleanLogicOperation* newOperation() { return new CBooleanLogicOperation(); }
81   virtual CBooleanLogicValue* newValue() { return new CBooleanLogicValue(); }
82   
83   BooleanLogicOperation m_operation;
84   CBooleanLogicOperations m_operations;
85   CBooleanLogicValues m_values;
86 };
87
88 class CBooleanLogic : public IXmlDeserializable
89 {
90 public:
91   CBooleanLogic() { }
92   virtual ~CBooleanLogic() { }
93
94   virtual bool Deserialize(const TiXmlNode *node);
95
96   virtual const CBooleanLogicOperationPtr& Get() const { return m_operation; }
97   virtual CBooleanLogicOperationPtr Get() { return m_operation; }
98
99 protected:
100   CBooleanLogicOperationPtr m_operation;
101 };