1 /* 2 ----------------------------------------------------------------------------- 3 This source file is part of OGRE 4 (Object-oriented Graphics Rendering Engine) 5 For the latest info, see http://www.ogre3d.org/ 6 7 Copyright (c) 2000-2013 Torus Knot Software Ltd 8 9 Permission is hereby granted, free of charge, to any person obtaining a copy 10 of this software and associated documentation files (the "Software"), to deal 11 in the Software without restriction, including without limitation the rights 12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 copies of the Software, and to permit persons to whom the Software is 14 furnished to do so, subject to the following conditions: 15 16 The above copyright notice and this permission notice shall be included in 17 all copies or substantial portions of the Software. 18 19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 THE SOFTWARE. 26 ----------------------------------------------------------------------------- 27 */ 28 #ifndef _SELECTIONSERVICE_H_ 29 #define _SELECTIONSERVICE_H_ 30 31 #include "OgreSingleton.h" 32 33 #include "EventContainer.h" 34 35 namespace boost 36 { 37 class any; 38 } 39 40 typedef std::list<boost::any> SelectionList; 41 42 class SelectionService : public Ogre::Singleton<SelectionService>, public EventContainer 43 { 44 public: 45 enum SelectionEvent 46 { 47 SelectionChanged 48 }; 49 50 SelectionService(); 51 virtual ~SelectionService(); 52 53 const SelectionList& getSelection() const; 54 void setSelection(boost::any& sel); 55 void setSelection(const SelectionList& sel); 56 57 /** Override standard Singleton retrieval. 58 @remarks 59 Why do we do this? Well, it's because the Singleton 60 implementation is in a .h file, which means it gets compiled 61 into anybody who includes it. This is needed for the 62 Singleton template to work, but we actually only want it 63 compiled into the implementation of the class based on the 64 Singleton, not all of them. If we don't change this, we get 65 link errors when trying to use the Singleton-based class from 66 an outside dll. 67 @par 68 This method just delegates to the template version anyway, 69 but the implementation stays in this single compilation unit, 70 preventing link errors. 71 */ 72 static SelectionService& getSingleton(void); 73 74 /** Override standard Singleton retrieval. 75 @remarks 76 Why do we do this? Well, it's because the Singleton 77 implementation is in a .h file, which means it gets compiled 78 into anybody who includes it. This is needed for the 79 Singleton template to work, but we actually only want it 80 compiled into the implementation of the class based on the 81 Singleton, not all of them. If we don't change this, we get 82 link errors when trying to use the Singleton-based class from 83 an outside dll. 84 @par 85 This method just delegates to the template version anyway, 86 but the implementation stays in this single compilation unit, 87 preventing link errors. 88 */ 89 static SelectionService* getSingletonPtr(void); 90 91 protected: 92 void registerEvents(); 93 94 SelectionList mSelection; 95 }; 96 97 98 99 #endif _SELECTIONSERVICE_H_