49 template <
typename T_FROM,
typename T_TO>
50 static std::vector<T_TO*>
filter(
const std::vector<T_FROM*>& v)
52 std::vector<T_TO*> result;
53 for(
int i = 0; i < v.size(); i++) {
54 T_TO* t = cast<T_FROM, T_TO>(v[i]);
70 template <
typename T_FROM,
typename T_TO>
71 static std::vector<const T_TO*>
constFilter(
const std::vector<T_FROM*>& v)
73 std::vector<const T_TO*> result;
74 for(
int i = 0; i < v.size(); i++) {
75 const T_TO* t = cast<T_FROM, T_TO>(v[i]);
86 template <
typename T_FROM,
typename T_TO>
87 static T_TO*
cast(T_FROM* obj)
91 return dynamic_cast<T_TO*
>(obj);
92 }
catch (std::exception& e) {
101 template <
typename T_FROM,
typename T_TO>
102 static const T_TO*
cast(
const T_FROM* obj)
106 return dynamic_cast<const T_TO*
>(obj);
107 }
catch (std::exception& e) {
115 template <
typename T_FROM,
typename T_TO>
118 return cast<T_FROM, T_TO>(&obj);
121 template <
typename T_FROM,
typename T_TO>
122 static std::vector<T_TO*> find(
const tgTagSearch& tagSearch,
const std::vector<T_FROM*> haystack)
125 std::vector<T_TO*> filtered = filter<T_FROM, T_TO>(haystack);
126 std::vector<T_TO*> result;
129 for(
int i = 0; i < filtered.size(); i++) {
130 tgTaggable* t = cast<T_TO, tgTaggable>(filtered[i]);
131 if(t != 0 && tagSearch.
matches(*t)) {
133 result.push_back(filtered[i]);
static T_TO * cast(T_FROM &obj)
static T_TO * cast(T_FROM *obj)
Contains the definition of class tgTagSearch.
static std::vector< const T_TO * > constFilter(const std::vector< T_FROM * > &v)
const bool matches(const tgTags &tags) const
Contains the definition of class tgTaggable.
static std::vector< T_TO * > filter(const std::vector< T_FROM * > &v)
static const T_TO * cast(const T_FROM *obj)