[gnome-dvb-daemon/gst-1.0: 3/4] port to libgee 0.8
- From: Sebastian Polsterl <sebp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-dvb-daemon/gst-1.0: 3/4] port to libgee 0.8
- Date: Sat, 12 Oct 2013 18:55:47 +0000 (UTC)
commit f32e34fa713836d6c3b09425123282525c88c547
Author: Sebastian Pölsterl <sebp k-d-w org>
Date: Sat Mar 16 16:55:39 2013 +0100
port to libgee 0.8
src/ChannelList.vala | 6 +++++-
src/Device.vala | 10 +++++-----
src/DeviceGroup.vala | 11 ++++++++---
src/EPGScanner.vala | 12 ++++++------
src/Event.vala | 8 ++++----
src/EventStorage.vala | 34 ++++++++++++++++++++++++++--------
src/Logging.vala | 10 +++++++---
src/Manager.vala | 6 ++++--
src/Recorder.vala | 8 ++++++--
src/ScannedItem.vala | 10 +++++-----
src/Scanner.vala | 22 +++++++++++-----------
11 files changed, 87 insertions(+), 50 deletions(-)
---
diff --git a/src/ChannelList.vala b/src/ChannelList.vala
index 713271d..43a6673 100644
--- a/src/ChannelList.vala
+++ b/src/ChannelList.vala
@@ -25,7 +25,7 @@ using DVB.Logging;
namespace DVB {
- public class ChannelList : GLib.Object, Iterable<Channel>, IDBusChannelList {
+ public class ChannelList : GLib.Object, Traversable<Channel>, Iterable<Channel>, IDBusChannelList {
private static Logger log = LogManager.getLogManager().getDefaultLogger();
@@ -89,6 +89,10 @@ namespace DVB {
return this.channels.values.iterator();
}
+ public bool foreach(ForallFunc<Channel> f) {
+ return this.channels.iterator().foreach(f);
+ }
+
public void load (AdapterType type) throws Error {
var reader = new DVB.io.ChannelListReader (this, type);
reader.read_into ();
diff --git a/src/Device.vala b/src/Device.vala
index 0a422eb..f7b17b1 100644
--- a/src/Device.vala
+++ b/src/Device.vala
@@ -98,17 +98,17 @@ namespace DVB {
return device;
}
- public static bool equal (Device* dev1, Device* dev2) {
+ public static bool equal (Device dev1, Device dev2) {
if (dev1 == null || dev2 == null) return false;
- return (dev1->Adapter == dev2->Adapter
- && dev2->Frontend == dev2->Frontend);
+ return (dev1.Adapter == dev2.Adapter
+ && dev2.Frontend == dev2.Frontend);
}
- public static uint hash (Device *device) {
+ public static uint hash (Device device) {
if (device == null) return 0;
- return hash_without_device (device->Adapter, device->Frontend);
+ return hash_without_device (device.Adapter, device.Frontend);
}
public static uint hash_without_device (uint adapter, uint frontend) {
diff --git a/src/DeviceGroup.vala b/src/DeviceGroup.vala
index 154f1ca..91c844f 100644
--- a/src/DeviceGroup.vala
+++ b/src/DeviceGroup.vala
@@ -28,7 +28,7 @@ namespace DVB {
* A group of devices that share the same settings
* (list of channels, recordings dir)
*/
- public class DeviceGroup : GLib.Object, IDBusDeviceGroup, Iterable<Device> {
+ public class DeviceGroup : GLib.Object, IDBusDeviceGroup, Traversable<Device>, Iterable<Device> {
private static Logger log = LogManager.getLogManager().getDefaultLogger();
@@ -76,8 +76,9 @@ namespace DVB {
construct {
this.devices = new HashSet<Device> (Device.hash, Device.equal);
- this.schedules = new HashSet<string> (GLib.str_hash,
- GLib.str_equal);
+ this.schedules = new HashSet<string> (
+ Gee.Functions.get_hash_func_for(typeof(string)),
+ Gee.Functions.get_equal_func_for(typeof(string)));
this.devices.add (this.reference_device);
this._channelfactory = new ChannelFactory (this);
this._recorder = new Recorder (this);
@@ -455,6 +456,10 @@ namespace DVB {
return this.devices.iterator();
}
+ public bool foreach (ForallFunc<Device> f) {
+ return this.devices.iterator().foreach(f);
+ }
+
/**
* Set RecordingsDirectory property of all
* devices to the values of the reference device
diff --git a/src/EPGScanner.vala b/src/EPGScanner.vala
index 32c789a..68c0d65 100644
--- a/src/EPGScanner.vala
+++ b/src/EPGScanner.vala
@@ -266,13 +266,13 @@ namespace DVB {
}
public void on_eit_structure (Gst.Structure structure) {
- Gst.Value events = structure.get_value ("events");
+ Value events = structure.get_value ("events");
- if (!(events.holds (Gst.Value.list_get_type ())))
+ if (!(events.holds (Value.list_get_type ())))
return;
uint size = events.list_get_size ();
- Gst.Value val;
+ Value val;
weak Gst.Structure event;
// Iterate over events
lock (this.channel_events) {
@@ -314,7 +314,7 @@ namespace DVB {
event.get_boolean ("free-ca-mode", out free_ca);
event_class.free_ca_mode = free_ca;
/*
- Gst.Value components = event.get_value ("components");
+ Value components = event.get_value ("components");
add_components (components, event_class);
*/
//log.debug ("Adding new event: %s", event_class.to_string ());
@@ -324,10 +324,10 @@ namespace DVB {
}
}
/*
- private static void add_components (Gst.Value components, Event event_class) {
+ private static void add_components (Value components, Event event_class) {
uint components_len = components.list_get_size ();
- Gst.Value comp_val;
+ Value comp_val;
weak Gst.Structure component;
for (uint j=0; j<components_len; j++) {
comp_val = components.list_get_value (j);
diff --git a/src/Event.vala b/src/Event.vala
index 01ca2d9..a2ec453 100644
--- a/src/Event.vala
+++ b/src/Event.vala
@@ -194,14 +194,14 @@ namespace DVB {
*
* event1 and event2 must be part of the same transport stream
*/
- public static bool equal (Event* event1, Event* event2) {
+ public static bool equal (Event event1, Event event2) {
if (event1 == null || event2 == null) return false;
- return (event1->id == event2->id);
+ return (event1.id == event2.id);
}
- public static uint hash (Event* event) {
- return event->id;
+ public static uint hash (Event event) {
+ return event.id;
}
public class AudioComponent {
diff --git a/src/EventStorage.vala b/src/EventStorage.vala
index 59ef51f..475a01c 100644
--- a/src/EventStorage.vala
+++ b/src/EventStorage.vala
@@ -51,7 +51,7 @@ namespace DVB {
}
}
- public class EventStorage : GLib.Object, Iterable<EventElement> {
+ public class EventStorage : GLib.Object, Traversable<EventElement>, Iterable<EventElement> {
private Sequence<EventElement> events;
private Map<uint, unowned SequenceIter<EventElement>> event_id_map;
@@ -96,13 +96,13 @@ namespace DVB {
SequenceIter<EventElement> iter = begin_iter;
while (iter != end_iter) {
- EventElement element = this.events.get (iter);
+ EventElement element = iter.get();
this.event_id_map.unset (element.id);
iter = iter.next ();
}
- this.events.remove_range (begin_iter, end_iter);
+ Sequence.remove_range (begin_iter, end_iter);
_stamp++;
@@ -113,7 +113,7 @@ namespace DVB {
foreach (Event event in events) {
SequenceIter<EventElement> iter = this.event_id_map.get (event.id);
if (iter != null) {
- this.events.remove (iter);
+ Sequence.remove (iter);
this.event_id_map.unset (event.id);
}
}
@@ -124,14 +124,14 @@ namespace DVB {
assert (index < this.events.get_length ());
SequenceIter<EventElement> iter = this.events.get_iter_at_pos (index);
- EventElement element = this.events.get (iter);
+ EventElement element = iter.get ();
return element;
}
public EventElement get_by_id (uint event_id) {
SequenceIter<EventElement> iter = this.event_id_map.get (event_id);
- EventElement element = this.events.get (iter);
+ EventElement element = iter.get ();
return element;
}
@@ -177,6 +177,11 @@ namespace DVB {
return overlap;
}
+ public bool foreach (ForallFunc<EventElement> f) {
+ Iterator<EventElement> iter = this.iterator();
+ return iter.foreach(f);
+ }
+
public Iterator<EventElement> iterator () {
return new EventIterator (this);
}
@@ -185,7 +190,7 @@ namespace DVB {
return new EventIterator (this);
}
- private class EventIterator : Object, Iterator<EventElement>, BidirIterator<EventElement> {
+ private class EventIterator : Object, Traversable<EventElement>, Iterator<EventElement>,
BidirIterator<EventElement> {
private EventStorage _storage;
private SequenceIter<EventElement> _iter;
@@ -198,6 +203,9 @@ namespace DVB {
this._stamp = storage._stamp;
}
+ public bool valid { get { return true; }}
+ public bool read_only { get { return true; }}
+
public bool next () {
assert (_stamp == _storage._stamp);
if (!_iter.is_end ()) {
@@ -225,7 +233,7 @@ namespace DVB {
assert (_stamp == _storage._stamp);
assert (_iter != null);
- return _storage.events.get (_iter);
+ return _iter.get ();
}
public void remove () {
@@ -254,6 +262,16 @@ namespace DVB {
}
return false;
}
+
+ public bool foreach (ForallFunc<EventElement> f) {
+ assert (_stamp == _storage._stamp);
+ while (!_iter.is_end ()) {
+ _iter = _iter.next ();
+ if (!f(_iter.get()))
+ return false;
+ }
+ return true;
+ }
}
}
diff --git a/src/Logging.vala b/src/Logging.vala
index 7103292..8a2e134 100644
--- a/src/Logging.vala
+++ b/src/Logging.vala
@@ -199,7 +199,9 @@ public class Logger : GLib.Object {
private Gee.HashSet<Handler> handlers;
construct {
- this.handlers = new Gee.HashSet<Handler> (GLib.direct_hash, GLib.direct_equal);
+ this.handlers = new Gee.HashSet<Handler> (
+ Gee.Functions.get_hash_func_for(typeof(Handler)),
+ Gee.Functions.get_equal_func_for(typeof(Handler)));
}
public void addHandler (Handler handler) {
@@ -274,8 +276,10 @@ public class LogManager : GLib.Object {
private Gee.HashMap<string, Logger> loggers;
construct {
- this.loggers = new Gee.HashMap<string, Logger> (GLib.str_hash,
- GLib.str_equal, GLib.direct_equal);
+ this.loggers = new Gee.HashMap<string, Logger> (
+ Gee.Functions.get_hash_func_for(typeof(string)),
+ Gee.Functions.get_equal_func_for(typeof(string)),
+ Gee.Functions.get_equal_func_for(typeof(Logger)));
}
public static unowned LogManager getLogManager () {
diff --git a/src/Manager.vala b/src/Manager.vala
index 724b065..8fc41d4 100644
--- a/src/Manager.vala
+++ b/src/Manager.vala
@@ -52,8 +52,10 @@ namespace DVB {
private static const string[] UDEV_SUBSYSTEMS = {"dvb", null};
construct {
- this.scanners = new HashMap<string, ScannerData> (GLib.str_hash,
- GLib.str_equal, GLib.direct_equal);
+ this.scanners = new HashMap<string, ScannerData> (
+ Gee.Functions.get_hash_func_for(typeof(string)),
+ Gee.Functions.get_equal_func_for(typeof(string)),
+ Gee.Functions.get_equal_func_for(typeof(ScannerData)));
this.devices = new HashMap<uint, DeviceGroup> ();
this.device_group_counter = 0;
this.udev_client = new GUdev.Client (UDEV_SUBSYSTEMS);
diff --git a/src/Recorder.vala b/src/Recorder.vala
index 9c7ce6f..99b5bf8 100644
--- a/src/Recorder.vala
+++ b/src/Recorder.vala
@@ -28,7 +28,7 @@ namespace DVB {
* This class is responsible for managing upcoming recordings and
* already recorded items for a single group of devices
*/
- public class Recorder : GLib.Object, IDBusRecorder, Iterable<Timer> {
+ public class Recorder : GLib.Object, IDBusRecorder, Traversable<Timer>, Iterable<Timer> {
private static Logger log = LogManager.getLogManager().getDefaultLogger();
@@ -65,12 +65,16 @@ namespace DVB {
base (DeviceGroup: dev);
}
- public Type element_type { get { return typeof (Timer); } }
+ public Type element_type { get { return typeof (Timer); } }
public Gee.Iterator<Timer> iterator () {
return this.timers.values.iterator ();
}
+ public bool foreach (ForallFunc<Timer> f) {
+ return this.timers.values.iterator().foreach(f);
+ }
+
/**
* @channel: Channel number
* @start_year: The year when the recording should start
diff --git a/src/ScannedItem.vala b/src/ScannedItem.vala
index 4d28fda..9b6e141 100644
--- a/src/ScannedItem.vala
+++ b/src/ScannedItem.vala
@@ -37,24 +37,24 @@ namespace DVB {
Object (Frequency: frequency);
}
- public static uint hash (ScannedItem* o) {
+ public static uint hash (ScannedItem o) {
uint hashval;
// Most specific class first
if (o is ScannedSatteliteItem) {
- hashval = 2 * PRIME + PRIME * o->Frequency
+ hashval = 2 * PRIME + PRIME * o.Frequency
+ ((ScannedSatteliteItem)o).Polarization.hash ();
} else if (o is ScannedItem) {
- hashval = o->Frequency;
+ hashval = o.Frequency;
} else {
hashval = 0;
}
return hashval;
}
- public static bool equal (ScannedItem* o1, ScannedItem* o2) {
+ public static bool equal (ScannedItem o1, ScannedItem o2) {
if (o1 == null || o2 == null) return false;
- if (o1->get_type().name() != o2->get_type().name()) return false;
+ if (o1.get_type().name() != o2.get_type().name()) return false;
if (o1 is ScannedSatteliteItem) {
ScannedSatteliteItem item1 = (ScannedSatteliteItem)o1;
diff --git a/src/Scanner.vala b/src/Scanner.vala
index 1d1b4f7..0cfa00e 100644
--- a/src/Scanner.vala
+++ b/src/Scanner.vala
@@ -525,9 +525,9 @@ namespace DVB {
pid_set.add (16);
pid_set.add (17);
- Gst.Value programs = structure.get_value ("programs");
+ Value programs = structure.get_value ("programs");
uint size = programs.list_get_size ();
- Gst.Value val;
+ Value val;
weak Gst.Structure program;
// Iterate over programs
for (uint i=0; i<size; i++) {
@@ -567,10 +567,10 @@ namespace DVB {
log.debug("Received SDT (0x%x)", tsid);
- Gst.Value services = structure.get_value ("services");
+ Value services = structure.get_value ("services");
uint size = services.list_get_size ();
- Gst.Value val;
+ Value val;
weak Gst.Structure service;
// Iterate over services
for (uint i=0; i<size; i++) {
@@ -636,9 +636,9 @@ namespace DVB {
}
log.debug ("Network name '%s'", name);
- Gst.Value transports = structure.get_value ("transports");
+ Value transports = structure.get_value ("transports");
uint size = transports.list_get_size ();
- Gst.Value val;
+ Value val;
weak Gst.Structure transport;
// Iterate over transports
for (uint i=0; i<size; i++) {
@@ -649,7 +649,7 @@ namespace DVB {
transport.get_uint ("transport-stream-id", out tsid);
if (transport.has_field ("delivery")) {
- Gst.Value delivery_val = transport.get_value ("delivery");
+ Value delivery_val = transport.get_value ("delivery");
weak Gst.Structure delivery =
delivery_val.get_structure ();
@@ -662,10 +662,10 @@ namespace DVB {
}
if (transport.has_field ("channels")) {
- Gst.Value channels = transport.get_value ("channels");
+ Value channels = transport.get_value ("channels");
uint channels_size = channels.list_get_size ();
- Gst.Value channel_val;
+ Value channel_val;
weak Gst.Structure channel_struct;
// Iterate over channels
for (int j=0; j<channels_size; j++) {
@@ -709,10 +709,10 @@ namespace DVB {
Channel dvb_channel = this.channels.get_channel (program_number);
- Gst.Value streams = structure.get_value ("streams");
+ Value streams = structure.get_value ("streams");
uint size = streams.list_get_size ();
- Gst.Value stream_val;
+ Value stream_val;
weak Gst.Structure stream;
// Iterate over streams
for (int i=0; i<size; i++) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]