Selector.h

Go to the documentation of this file.
00001 #ifndef SELECTOR_H_
00002 #define SELECTOR_H_
00003 
00004 #include <map>
00005 #include "selectable.h"
00006 
00007 typedef std::multimap<SelectionIntersection, Selectable*> SelectableSortedSet;
00008 
00009 class SelectionPool: public Selector
00010 {
00011         SelectableSortedSet m_pool;
00012         SelectionIntersection m_intersection;
00013         Selectable* m_selectable;
00014 
00015     public:
00016 
00017         void pushSelectable (Selectable& selectable)
00018         {
00019             m_intersection = SelectionIntersection();
00020             m_selectable = &selectable;
00021         }
00022 
00023         void popSelectable ()
00024         {
00025             addSelectable(m_intersection, m_selectable);
00026             m_intersection = SelectionIntersection();
00027         }
00028 
00029         void addIntersection (const SelectionIntersection& intersection)
00030         {
00031             assign_if_closer(m_intersection, intersection);
00032         }
00033 
00034         void addSelectable (const SelectionIntersection& intersection, Selectable* selectable)
00035         {
00036             if (intersection.valid()) {
00037                 m_pool.insert(SelectableSortedSet::value_type(intersection, selectable));
00038             }
00039         }
00040 
00041         typedef SelectableSortedSet::iterator iterator;
00042 
00043         iterator begin ()
00044         {
00045             return m_pool.begin();
00046         }
00047 
00048         iterator end ()
00049         {
00050             return m_pool.end();
00051         }
00052 
00053         bool failed ()
00054         {
00055             return m_pool.empty();
00056         }
00057 };
00058 
00059 #endif /*SELECTOR_H_*/

Generated by  doxygen 1.6.2