3
* Ekiga -- A VoIP and Video-Conferencing application
4
* Copyright (C) 2000-2009 Damien Sandras <dsandras@seconix.com>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or (at
9
* your option) any later version. This program is distributed in the hope
10
* that it will be useful, but WITHOUT ANY WARRANTY; without even the
11
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
* See the GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License along
15
* with this program; if not, write to the Free Software Foundation, Inc.,
16
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
18
* Ekiga is licensed under the GPL license and as a special exception, you
19
* have permission to link or otherwise combine this program with the
20
* programs OPAL, OpenH323 and PWLIB, and distribute the combination, without
21
* applying the requirements of the GNU GPL to the OPAL, OpenH323 and PWLIB
22
* programs, as long as you do follow the requirements of the GNU GPL for all
23
* the rest of the software thus combined.
28
* heap-impl.h - description
29
* ------------------------------------------
30
* begin : written in 2007 by Julien Puydt
31
* copyright : (c) 2007 by Julien Puydt
32
* description : declaration of a partial implementation
37
#ifndef __HEAP_IMPL_H__
38
#define __HEAP_IMPL_H__
40
#include "reflister.h"
47
* @addtogroup presence
51
/** Generic implementation for the Heap pure virtual class.
53
* This class is there to make it easy to implement a new type of presentity
54
* heap: it will take care of implementing the external api, you
55
* just have to decide when to add and remove presentities.
57
* Notice that this class won't take care of removing the presentity from a
58
* backend -- only from the heap. If you want the presentity <b>deleted</b>
59
* then you probably should have an organization like:
60
* - the presentity has a 'deleted' signal;
61
* - the heap listens for this signal;
62
* - when the signal is received, then do a remove_presentity followed by
63
* calling the appropriate api function to delete the presentity in your
66
template<typename PresentityType = Presentity>
69
protected RefLister<PresentityType>
74
typedef typename RefLister<PresentityType>::iterator iterator;
75
typedef typename RefLister<PresentityType>::const_iterator const_iterator;
81
void visit_presentities (boost::function1<bool, PresentityPtr > visitor) const;
83
const_iterator begin () const;
87
const_iterator end () const;
93
using RefLister<PresentityType>::add_connection;
95
void add_presentity (boost::shared_ptr<PresentityType> presentity);
97
void remove_presentity (boost::shared_ptr<PresentityType> presentity);
106
/* here are the implementations of the template methods */
107
template<typename PresentityType>
108
Ekiga::HeapImpl<PresentityType>::HeapImpl ()
110
/* this is signal forwarding */
111
RefLister<PresentityType>::object_added.connect (boost::ref (presentity_added));
112
RefLister<PresentityType>::object_removed.connect (boost::ref (presentity_removed));
113
RefLister<PresentityType>::object_updated.connect (boost::ref (presentity_updated));
117
template<typename PresentityType>
118
Ekiga::HeapImpl<PresentityType>::~HeapImpl ()
122
template<typename PresentityType>
124
Ekiga::HeapImpl<PresentityType>::visit_presentities (boost::function1<bool, PresentityPtr > visitor) const
126
RefLister<PresentityType>::visit_objects (visitor);
129
template<typename PresentityType>
130
typename Ekiga::HeapImpl<PresentityType>::iterator
131
Ekiga::HeapImpl<PresentityType>::begin ()
133
return RefLister<PresentityType>::begin ();
136
template<typename PresentityType>
137
typename Ekiga::HeapImpl<PresentityType>::iterator
138
Ekiga::HeapImpl<PresentityType>::end ()
140
return RefLister<PresentityType>::end ();
143
template<typename PresentityType>
144
typename Ekiga::HeapImpl<PresentityType>::const_iterator
145
Ekiga::HeapImpl<PresentityType>::begin () const
147
return RefLister<PresentityType>::begin ();
150
template<typename PresentityType>
151
typename Ekiga::HeapImpl<PresentityType>::const_iterator
152
Ekiga::HeapImpl<PresentityType>::end () const
154
return RefLister<PresentityType>::end ();
157
template<typename PresentityType>
159
Ekiga::HeapImpl<PresentityType>::add_presentity (boost::shared_ptr<PresentityType> presentity)
161
presentity->questions.connect (boost::ref (questions));
163
add_object (presentity);
166
template<typename PresentityType>
168
Ekiga::HeapImpl<PresentityType>::remove_presentity (boost::shared_ptr<PresentityType> presentity)
170
remove_object (presentity);