llviewquery.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLVIEWQUERY_H
00033 #define LL_LLVIEWQUERY_H
00034 
00035 #include <list> 
00036 
00037 #include "llmemory.h"
00038 
00039 class LLView;
00040 
00041 typedef std::list<LLView *>                     viewList_t;
00042 typedef std::pair<BOOL, BOOL>           filterResult_t;
00043 
00044 // Abstract base class for all filters.
00045 class LLQueryFilter : public LLRefCount
00046 {
00047 public:
00048         virtual filterResult_t operator() (const LLView* const view, const viewList_t & children) const =0;
00049 };
00050 
00051 class LLQuerySorter : public LLRefCount
00052 {
00053 public:
00054         virtual void operator() (LLView * parent, viewList_t &children) const;
00055 };
00056 
00057 class LLNoLeavesFilter : public LLQueryFilter, public LLSingleton<LLNoLeavesFilter>
00058 {
00059         /*virtual*/ filterResult_t operator() (const LLView* const view, const viewList_t & children) const;
00060 };
00061 class LLVisibleFilter : public LLQueryFilter, public LLSingleton<LLVisibleFilter>
00062 {
00063         /*virtual*/ filterResult_t operator() (const LLView* const view, const viewList_t & children) const;
00064 };
00065 class LLEnabledFilter : public LLQueryFilter, public LLSingleton<LLEnabledFilter>
00066 {
00067         /*virtual*/ filterResult_t operator() (const LLView* const view, const viewList_t & children) const;
00068 };
00069 class LLTabStopFilter : public LLQueryFilter, public LLSingleton<LLTabStopFilter>
00070 {
00071         /*virtual*/ filterResult_t operator() (const LLView* const view, const viewList_t & children) const;
00072 };
00073 
00074 // Algorithm for flattening
00075 class LLViewQuery
00076 {
00077 public:
00078         typedef std::list<const LLQueryFilter*>         filterList_t;
00079         typedef filterList_t::iterator                          filterList_iter_t;
00080         typedef filterList_t::const_iterator            filterList_const_iter_t;
00081 
00082         LLViewQuery();
00083         virtual ~LLViewQuery() {}
00084 
00085         void addPreFilter(const LLQueryFilter* prefilter);
00086         void addPostFilter(const LLQueryFilter* postfilter);
00087         const filterList_t & getPreFilters() const;
00088         const filterList_t & getPostFilters() const;
00089 
00090         void setSorter(const LLQuerySorter* sorter);
00091         const LLQuerySorter* getSorter() const;
00092 
00093         viewList_t run(LLView * view) const;
00094         // syntactic sugar
00095         viewList_t operator () (LLView * view) const { return run(view); }
00096 protected:
00097         // override this method to provide iteration over other types of children
00098         virtual void filterChildren(LLView * view, viewList_t & filtered_children) const;
00099         filterResult_t runFilters(LLView * view, const viewList_t children, const filterList_t filters) const;
00100 protected:
00101         filterList_t mPreFilters;
00102         filterList_t mPostFilters;
00103         const LLQuerySorter* mSorterp;
00104 };
00105 
00106 class LLCtrlQuery : public LLViewQuery
00107 {
00108 public:
00109         LLCtrlQuery();
00110 };
00111 
00112 #endif

Generated on Thu Jul 1 06:09:35 2010 for Second Life Viewer by  doxygen 1.4.7