mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:23:52 +00:00
replaced binary filter node with a n-ary node
This commit is contained in:
parent
528e047fd5
commit
236dc9fc43
4 changed files with 71 additions and 71 deletions
|
@ -108,7 +108,7 @@ opencs_units_noqt (model/settings
|
|||
)
|
||||
|
||||
opencs_units_noqt (model/filter
|
||||
node unarynode binarynode leafnode booleannode
|
||||
node unarynode narynode leafnode booleannode
|
||||
)
|
||||
|
||||
opencs_hdrs_noqt (model/filter
|
||||
|
|
|
@ -1,58 +0,0 @@
|
|||
|
||||
#include "binarynode.hpp"
|
||||
|
||||
CSMFilter::BinaryNode::BinaryNode (boost::shared_ptr<Node> left, boost::shared_ptr<Node> right)
|
||||
: mLeft (left), mRight (right)
|
||||
{}
|
||||
|
||||
const CSMFilter::Node& CSMFilter::BinaryNode::getLeft() const
|
||||
{
|
||||
return *mLeft;
|
||||
}
|
||||
|
||||
CSMFilter::Node& CSMFilter::BinaryNode::getLeft()
|
||||
{
|
||||
return *mLeft;
|
||||
}
|
||||
|
||||
const CSMFilter::Node& CSMFilter::BinaryNode::getRight() const
|
||||
{
|
||||
return *mRight;
|
||||
}
|
||||
|
||||
CSMFilter::Node& CSMFilter::BinaryNode::getRight()
|
||||
{
|
||||
return *mRight;
|
||||
}
|
||||
|
||||
std::vector<std::string> CSMFilter::BinaryNode::getReferencedFilters() const
|
||||
{
|
||||
std::vector<std::string> left = mLeft->getReferencedFilters();
|
||||
|
||||
std::vector<std::string> right = mRight->getReferencedFilters();
|
||||
|
||||
left.insert (left.end(), right.begin(), right.end());
|
||||
|
||||
return left;
|
||||
}
|
||||
|
||||
std::vector<int> CSMFilter::BinaryNode::getReferencedColumns() const
|
||||
{
|
||||
std::vector<int> left = mLeft->getReferencedColumns();
|
||||
|
||||
std::vector<int> right = mRight->getReferencedColumns();
|
||||
|
||||
left.insert (left.end(), right.begin(), right.end());
|
||||
|
||||
return left;
|
||||
}
|
||||
|
||||
bool CSMFilter::BinaryNode::isSimple() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CSMFilter::BinaryNode::hasUserValue() const
|
||||
{
|
||||
return mLeft->hasUserValue() || mRight->hasUserValue();
|
||||
}
|
61
apps/opencs/model/filter/narynode.cpp
Normal file
61
apps/opencs/model/filter/narynode.cpp
Normal file
|
@ -0,0 +1,61 @@
|
|||
|
||||
#include "narynode.hpp"
|
||||
|
||||
CSMFilter::NAryNode::NAryNode (const std::vector<boost::shared_ptr<Node> >& nodes)
|
||||
: mNodes (nodes)
|
||||
{}
|
||||
|
||||
int CSMFilter::NAryNode::getSize() const
|
||||
{
|
||||
return mNodes.size();
|
||||
}
|
||||
|
||||
const CSMFilter::Node& CSMFilter::NAryNode::operator[] (int index) const
|
||||
{
|
||||
return *mNodes.at (index);
|
||||
}
|
||||
|
||||
std::vector<std::string> CSMFilter::NAryNode::getReferencedFilters() const
|
||||
{
|
||||
std::vector<std::string> filters;
|
||||
|
||||
for (std::vector<boost::shared_ptr<Node> >::const_iterator iter (mNodes.begin());
|
||||
iter!=mNodes.end(); ++iter)
|
||||
{
|
||||
std::vector<std::string> filters2 = (*iter)->getReferencedFilters();
|
||||
|
||||
filters.insert (filters.end(), filters2.begin(), filters2.end());
|
||||
}
|
||||
|
||||
return filters;
|
||||
}
|
||||
|
||||
std::vector<int> CSMFilter::NAryNode::getReferencedColumns() const
|
||||
{
|
||||
std::vector<int> columns;
|
||||
|
||||
for (std::vector<boost::shared_ptr<Node> >::const_iterator iter (mNodes.begin());
|
||||
iter!=mNodes.end(); ++iter)
|
||||
{
|
||||
std::vector<int> columns2 = (*iter)->getReferencedColumns();
|
||||
|
||||
columns.insert (columns.end(), columns2.begin(), columns2.end());
|
||||
}
|
||||
|
||||
return columns;
|
||||
}
|
||||
|
||||
bool CSMFilter::NAryNode::isSimple() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CSMFilter::NAryNode::hasUserValue() const
|
||||
{
|
||||
for (std::vector<boost::shared_ptr<Node> >::const_iterator iter (mNodes.begin());
|
||||
iter!=mNodes.end(); ++iter)
|
||||
if ((*iter)->hasUserValue())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
#ifndef CSM_FILTER_BINARYNODE_H
|
||||
#define CSM_FILTER_BINARYNODE_H
|
||||
#ifndef CSM_FILTER_NARYNODE_H
|
||||
#define CSM_FILTER_NARYNODE_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
|
@ -7,22 +9,17 @@
|
|||
|
||||
namespace CSMFilter
|
||||
{
|
||||
class BinaryNode : public Node
|
||||
class NAryNode : public Node
|
||||
{
|
||||
boost::shared_ptr<Node> mLeft;
|
||||
boost::shared_ptr<Node> mRight;
|
||||
std::vector<boost::shared_ptr<Node> > mNodes;
|
||||
|
||||
public:
|
||||
|
||||
BinaryNode (boost::shared_ptr<Node> left, boost::shared_ptr<Node> right);
|
||||
NAryNode (const std::vector<boost::shared_ptr<Node> >& nodes);
|
||||
|
||||
const Node& getLeft() const;
|
||||
int getSize() const;
|
||||
|
||||
Node& getLeft();
|
||||
|
||||
const Node& getRight() const;
|
||||
|
||||
Node& getRight();
|
||||
const Node& operator[] (int index) const;
|
||||
|
||||
virtual std::vector<std::string> getReferencedFilters() const;
|
||||
///< Return a list of filters that are used by this node (and must be passed as
|
Loading…
Reference in a new issue