~ubuntu-branches/ubuntu/vivid/ekiga/vivid-proposed

« back to all changes in this revision

Viewing changes to lib/engine/presence/heap-impl.h

  • Committer: Bazaar Package Importer
  • Author(s): Kilian Krause
  • Date: 2011-07-17 00:24:50 UTC
  • mfrom: (5.1.5 upstream) (7.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20110717002450-ytg3wsrc1ptd3153
Tags: 3.3.1-1
* New upstream release.
 - Required libpt-dev 2.10 and libopal-dev 3.10
* Fix debian/watch to catch new version
* Remove libnotify0.7.patch - included upstream
* Add libboost-dev and libboost-signals-dev to Build-Depends
* debian/rules: Don't install *.la files for new internal shared libs
* Fix Vcs URIs to point to correct desktop/experimental/ekiga tree

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/*
 
3
 * Ekiga -- A VoIP and Video-Conferencing application
 
4
 * Copyright (C) 2000-2009 Damien Sandras <dsandras@seconix.com>
 
5
 
 
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.
 
13
 *
 
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.
 
17
 *
 
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.
 
24
 */
 
25
 
 
26
 
 
27
/*
 
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
 
33
 *                          of a heap
 
34
 *
 
35
 */
 
36
 
 
37
#ifndef __HEAP_IMPL_H__
 
38
#define __HEAP_IMPL_H__
 
39
 
 
40
#include "reflister.h"
 
41
#include "heap.h"
 
42
 
 
43
namespace Ekiga
 
44
{
 
45
 
 
46
/**
 
47
 * @addtogroup presence
 
48
 * @{
 
49
 */
 
50
 
 
51
  /** Generic implementation for the Heap pure virtual class.
 
52
   *
 
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.
 
56
   *
 
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
 
64
   *    backend.
 
65
   */
 
66
  template<typename PresentityType = Presentity>
 
67
  class HeapImpl:
 
68
    public Heap,
 
69
    protected RefLister<PresentityType>
 
70
  {
 
71
 
 
72
  public:
 
73
 
 
74
    typedef typename RefLister<PresentityType>::iterator iterator;
 
75
    typedef typename RefLister<PresentityType>::const_iterator const_iterator;
 
76
 
 
77
    HeapImpl ();
 
78
 
 
79
    ~HeapImpl ();
 
80
 
 
81
    void visit_presentities (boost::function1<bool, PresentityPtr > visitor) const;
 
82
 
 
83
    const_iterator begin () const;
 
84
 
 
85
    iterator begin ();
 
86
 
 
87
    const_iterator end () const;
 
88
 
 
89
    iterator end ();
 
90
 
 
91
  protected:
 
92
 
 
93
    using RefLister<PresentityType>::add_connection;
 
94
 
 
95
    void add_presentity (boost::shared_ptr<PresentityType> presentity);
 
96
 
 
97
    void remove_presentity (boost::shared_ptr<PresentityType> presentity);
 
98
  };
 
99
 
 
100
/**
 
101
 * @}
 
102
 */
 
103
 
 
104
};
 
105
 
 
106
/* here are the implementations of the template methods */
 
107
template<typename PresentityType>
 
108
Ekiga::HeapImpl<PresentityType>::HeapImpl ()
 
109
{
 
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));
 
114
}
 
115
 
 
116
 
 
117
template<typename PresentityType>
 
118
Ekiga::HeapImpl<PresentityType>::~HeapImpl ()
 
119
{
 
120
}
 
121
 
 
122
template<typename PresentityType>
 
123
void
 
124
Ekiga::HeapImpl<PresentityType>::visit_presentities (boost::function1<bool, PresentityPtr > visitor) const
 
125
{
 
126
  RefLister<PresentityType>::visit_objects (visitor);
 
127
}
 
128
 
 
129
template<typename PresentityType>
 
130
typename Ekiga::HeapImpl<PresentityType>::iterator
 
131
Ekiga::HeapImpl<PresentityType>::begin ()
 
132
{
 
133
  return RefLister<PresentityType>::begin ();
 
134
}
 
135
 
 
136
template<typename PresentityType>
 
137
typename Ekiga::HeapImpl<PresentityType>::iterator
 
138
Ekiga::HeapImpl<PresentityType>::end ()
 
139
{
 
140
  return RefLister<PresentityType>::end ();
 
141
}
 
142
 
 
143
template<typename PresentityType>
 
144
typename Ekiga::HeapImpl<PresentityType>::const_iterator
 
145
Ekiga::HeapImpl<PresentityType>::begin () const
 
146
{
 
147
  return RefLister<PresentityType>::begin ();
 
148
}
 
149
 
 
150
template<typename PresentityType>
 
151
typename Ekiga::HeapImpl<PresentityType>::const_iterator
 
152
Ekiga::HeapImpl<PresentityType>::end () const
 
153
{
 
154
  return RefLister<PresentityType>::end ();
 
155
}
 
156
 
 
157
template<typename PresentityType>
 
158
void
 
159
Ekiga::HeapImpl<PresentityType>::add_presentity (boost::shared_ptr<PresentityType> presentity)
 
160
{
 
161
  presentity->questions.connect (boost::ref (questions));
 
162
 
 
163
  add_object (presentity);
 
164
}
 
165
 
 
166
template<typename PresentityType>
 
167
void
 
168
Ekiga::HeapImpl<PresentityType>::remove_presentity (boost::shared_ptr<PresentityType> presentity)
 
169
{
 
170
  remove_object (presentity);
 
171
}
 
172
 
 
173
#endif