Robot Simulator of the Robotics Group for Self-Organization of Control  0.8.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
backcallervector.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2011 LpzRobots development team *
3  * Georg Martius <georg dot martius at web dot de> *
4  * Frank Guettler <guettler at informatik dot uni-leipzig dot de *
5  * Frank Hesse <frank at nld dot ds dot mpg dot de> *
6  * Ralf Der <ralfder at mis dot mpg dot de> *
7  * *
8  * This program is free software; you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation; either version 2 of the License, or *
11  * (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this program; if not, write to the *
20  * Free Software Foundation, Inc., *
21  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
22  * *
23  ***************************************************************************/
24 
25 #ifndef __BACKCALLERVECTOR_H_
26 #define __BACKCALLERVECTOR_H_
27 
28 #include <vector>
29 
30 /**
31  * Establishes for some methods the notifications for registered Callbackable instances
32  * (use addCallbackable(...)).
33  * @warning Only the following methods are currently supported:
34  push_back(...), pop_back(), erase() and clear()!
35  * You can use iterators with the limitation to not delete or insert.
36  */
37 template<typename _Tp, typename _Alloc = std::allocator<_Tp> >
38 class BackCallerVector : public std::vector<_Tp,_Alloc>, public BackCaller {
39 public:
40 
41  typedef typename std::vector<_Tp,_Alloc>::iterator iterator;
42 
44  virtual ~BackCallerVector(){
46  }
47 
48  /**
49  * Indicates that the list/vector has been modified,
50  a new instance was either added or removed.
51  */
53 
54  /**
55  * Indicates that the list is being deleted.
56  */
58 
59 
60  void push_back(const _Tp & i){
61  std::vector<_Tp,_Alloc>::push_back(i);
63  }
64 
66  iterator i = std::vector<_Tp,_Alloc>::erase(pos);
68  return i;
69  }
70 
71  void pop_back(){
72  std::vector<_Tp,_Alloc>::pop_back();
74  }
75 
76  void clear(){
77  std::vector<_Tp,_Alloc>::clear();
79  }
80 };
81 
82 #endif /* __BACKCALLERVECTOR_H_ */
83 
static const CallbackableType BACKCALLER_VECTOR_MODIFIED
Indicates that the list/vector has been modified, a new instance was either added or removed...
Definition: backcallervector.h:52
virtual void callBack(CallbackableType type=BackCaller::DEFAULT_CALLBACKABLE_TYPE)
Calls all registered callbackable classes of the determined type.
Definition: backcaller.cpp:86
iterator erase(iterator pos)
Definition: backcallervector.h:65
unsigned long CallbackableType
Definition: backcaller.h:45
std::vector< _Tp, _Alloc >::iterator iterator
Definition: backcallervector.h:41
void push_back(const _Tp &i)
Definition: backcallervector.h:60
BackCallerVector()
Definition: backcallervector.h:43
void clear()
Definition: backcallervector.h:76
void pop_back()
Definition: backcallervector.h:71
Establishes for some methods the notifications for registered Callbackable instances (use addCallback...
Definition: backcallervector.h:38
virtual ~BackCallerVector()
Definition: backcallervector.h:44
static const CallbackableType BACKCALLER_VECTOR_BEING_DELETED
Indicates that the list is being deleted.
Definition: backcallervector.h:57
Class prototype which provides functions to handle callbackable classes.
Definition: backcaller.h:42