18 class PropertyFilter::Impl
25 std::map<std::string, BaseProperty::Pointer>
Apply(
26 const std::map<std::string, BaseProperty::Pointer> &propertyMap)
const;
33 void AddEntry(
const std::string &propertyName, std::vector<std::string> &list);
34 bool HasEntry(
const std::string &propertyName,
const std::vector<std::string> &list)
const;
36 void RemoveEntry(
const std::string &propertyName, std::vector<std::string> &list);
38 std::vector<std::vector<std::string>> m_Lists;
41 PropertyFilter::Impl::Impl() : m_Lists(2) {}
42 PropertyFilter::Impl::~Impl() {}
43 void mitk::PropertyFilter::Impl::AddEntry(
const std::string &propertyName, List list)
45 this->AddEntry(propertyName, m_Lists.at(list));
48 void PropertyFilter::Impl::AddEntry(
const std::string &propertyName, std::vector<std::string> &list)
50 if (std::find(list.begin(), list.end(), propertyName) == list.end())
51 list.push_back(propertyName);
54 std::map<std::string, BaseProperty::Pointer> PropertyFilter::Impl::Apply(
55 const std::map<std::string, BaseProperty::Pointer> &propertyMap)
const 57 std::map<std::string, BaseProperty::Pointer> ret =
58 !m_Lists[Whitelist].empty() ? std::map<std::string, BaseProperty::Pointer>() : propertyMap;
60 if (!m_Lists[Whitelist].empty())
62 auto end = propertyMap.end();
64 for (
auto iter = propertyMap.begin(); iter != end; ++iter)
66 if (std::find(m_Lists[Whitelist].begin(), m_Lists[Whitelist].end(), iter->first) != m_Lists[Whitelist].end())
71 if (!m_Lists[Blacklist].empty())
73 auto end = m_Lists[Blacklist].end();
75 for (
auto iter = m_Lists[Blacklist].begin(); iter != end; ++iter)
82 bool mitk::PropertyFilter::Impl::HasEntry(
const std::string &propertyName, List list)
const 84 return this->HasEntry(propertyName, m_Lists.at(list));
87 bool PropertyFilter::Impl::HasEntry(
const std::string &propertyName,
const std::vector<std::string> &list)
const 89 return std::find(list.begin(), list.end(), propertyName) != list.end();
92 bool PropertyFilter::Impl::IsEmpty()
const 94 auto end = m_Lists.end();
96 for (
auto iter = m_Lists.begin(); iter != end; ++iter)
105 void mitk::PropertyFilter::Impl::RemoveAllEntries(List list) { this->RemoveAllEntries(m_Lists.at(list)); }
106 void PropertyFilter::Impl::RemoveAllEntries(std::vector<std::string> &list) { list.clear(); }
107 void mitk::PropertyFilter::Impl::RemoveEntry(
const std::string &propertyName, List list)
109 this->RemoveEntry(propertyName, m_Lists.at(list));
112 void PropertyFilter::Impl::RemoveEntry(
const std::string &propertyName, std::vector<std::string> &list)
114 auto iter = std::find(list.begin(), list.end(), propertyName);
116 if (iter != list.end())
142 if (!propertyName.empty())
143 m_Impl->AddEntry(propertyName, list);
147 const std::map<std::string, mitk::BaseProperty::Pointer> &propertyMap)
const 149 return m_Impl->Apply(propertyMap);
154 return !propertyName.empty() ? m_Impl->HasEntry(propertyName, list) :
false;
159 return m_Impl->IsEmpty();
164 m_Impl->RemoveAllEntries(list);
169 if (!propertyName.empty())
170 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.
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.
PropertyFilter & operator=(PropertyFilter other)
static void swap(T &x, T &y)
bool IsEmpty() const
Check if filter is empty.
bool HasEntry(const std::string &propertyName, List list) const
Check if filter has specific entry.
std::map< std::string, BaseProperty::Pointer > Apply(const std::map< std::string, BaseProperty::Pointer > &propertyMap) const
Apply the filter to a property list.
Consists of blacklist and whitelist entries.