22 class PropertyFilter::Impl
29 std::map<std::string, BaseProperty::Pointer>
Apply(
30 const std::map<std::string, BaseProperty::Pointer> &propertyMap)
const;
37 void AddEntry(
const std::string &propertyName, std::vector<std::string> &list);
38 bool HasEntry(
const std::string &propertyName,
const std::vector<std::string> &list)
const;
40 void RemoveEntry(
const std::string &propertyName, std::vector<std::string> &list);
42 std::vector<std::vector<std::string>> m_Lists;
45 PropertyFilter::Impl::Impl() : m_Lists(2) {}
46 PropertyFilter::Impl::~Impl() {}
47 void mitk::PropertyFilter::Impl::AddEntry(
const std::string &propertyName, List list)
49 this->AddEntry(propertyName, m_Lists.at(list));
52 void PropertyFilter::Impl::AddEntry(
const std::string &propertyName, std::vector<std::string> &list)
54 if (std::find(list.begin(), list.end(), propertyName) == list.end())
55 list.push_back(propertyName);
58 std::map<std::string, BaseProperty::Pointer> PropertyFilter::Impl::Apply(
59 const std::map<std::string, BaseProperty::Pointer> &propertyMap)
const
61 std::map<std::string, BaseProperty::Pointer> ret =
62 !m_Lists[Whitelist].empty() ? std::map<std::string, BaseProperty::Pointer>() : propertyMap;
64 if (!m_Lists[Whitelist].empty())
66 auto end = propertyMap.end();
68 for (
auto iter = propertyMap.begin(); iter != end; ++iter)
70 if (std::find(m_Lists[Whitelist].begin(), m_Lists[Whitelist].end(), iter->first) != m_Lists[Whitelist].end())
75 if (!m_Lists[Blacklist].empty())
77 auto end = m_Lists[Blacklist].end();
79 for (
auto iter = m_Lists[Blacklist].begin(); iter != end; ++iter)
86 bool mitk::PropertyFilter::Impl::HasEntry(
const std::string &propertyName, List list)
const
88 return this->HasEntry(propertyName, m_Lists.at(list));
91 bool PropertyFilter::Impl::HasEntry(
const std::string &propertyName,
const std::vector<std::string> &list)
const
93 return std::find(list.begin(), list.end(), propertyName) != list.end();
96 bool PropertyFilter::Impl::IsEmpty()
const
98 auto end = m_Lists.end();
100 for (
auto iter = m_Lists.begin(); iter != end; ++iter)
109 void mitk::PropertyFilter::Impl::RemoveAllEntries(List list) { this->RemoveAllEntries(m_Lists.at(list)); }
110 void PropertyFilter::Impl::RemoveAllEntries(std::vector<std::string> &list) { list.clear(); }
111 void mitk::PropertyFilter::Impl::RemoveEntry(
const std::string &propertyName, List list)
113 this->RemoveEntry(propertyName, m_Lists.at(list));
116 void PropertyFilter::Impl::RemoveEntry(
const std::string &propertyName, std::vector<std::string> &list)
118 auto iter = std::find(list.begin(), list.end(), propertyName);
120 if (iter != list.end())
146 if (!propertyName.empty())
147 m_Impl->AddEntry(propertyName, list);
151 const std::map<std::string, mitk::BaseProperty::Pointer> &propertyMap)
const
153 return m_Impl->Apply(propertyMap);
158 return !propertyName.empty() ?
m_Impl->HasEntry(propertyName, list) :
false;
168 m_Impl->RemoveAllEntries(list);
173 if (!propertyName.empty())
174 m_Impl->RemoveEntry(propertyName, list);
List
Specifies the type of a filter entry.
void AddEntry(const std::string &propertyName, List list)
Add a filter entry for a specific property.
std::map< std::string, BaseProperty::Pointer > Apply(const std::map< std::string, BaseProperty::Pointer > &propertyMap) const
Apply the filter to a property list.
DataCollection - Class to facilitate loading/accessing structured data.
void RemoveEntry(const std::string &propertyName, List list)
Remove specific entry from property filter.
void RemoveAllEntries(List list)
Remove all entries from property filter.
bool IsEmpty() const
Check if filter is empty.
PropertyFilter & operator=(PropertyFilter other)
bool HasEntry(const std::string &propertyName, List list) const
Check if filter has specific entry.
static void swap(T &x, T &y)
Consists of blacklist and whitelist entries.