All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ListenerFactoryLogic.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2014 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef _LISTENER_FACTORY_LOGIC_HH_
18 #define _LISTENER_FACTORY_LOGIC_HH_
19 
20 #include <OgreCompositorInstance.h>
21 #include <OgreCompositorLogic.h>
22 #include <map>
23 #include "gazebo/util/system.hh"
24 
25 namespace gazebo
26 {
27  namespace rendering
28  {
31  class GAZEBO_VISIBLE ListenerFactoryLogic : public Ogre::CompositorLogic
32  {
34  public: virtual void compositorInstanceCreated(
35  Ogre::CompositorInstance *_newInstance)
36  {
37  Ogre::CompositorInstance::Listener *listener =
38  createListener(_newInstance);
39 
40  _newInstance->addListener(listener);
41  this->listeners[_newInstance] = listener;
42  }
43 
45  public: virtual void compositorInstanceDestroyed(
46  Ogre::CompositorInstance *_destroyedInstance)
47  {
48  delete this->listeners[_destroyedInstance];
49  this->listeners.erase(_destroyedInstance);
50  }
51 
52  // This is the method that implementers will need to create
53  protected: virtual Ogre::CompositorInstance::Listener *createListener(
54  Ogre::CompositorInstance *instance) = 0;
55 
56  private: typedef std::map<Ogre::CompositorInstance*,
57  Ogre::CompositorInstance::Listener*> ListenerMap;
58 
59  ListenerMap listeners;
60  };
61  }
62 }
63 #endif
The simple types of compositor logics will all do the same thing - Attach a listener to the created c...
Definition: ListenerFactoryLogic.hh:31
virtual void compositorInstanceCreated(Ogre::CompositorInstance *_newInstance)
Definition: ListenerFactoryLogic.hh:34
virtual void compositorInstanceDestroyed(Ogre::CompositorInstance *_destroyedInstance)
Definition: ListenerFactoryLogic.hh:45
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:48