Main Page | Data Structures | File List | Data Fields | Globals

queue.h

Go to the documentation of this file.
00001 /**
00002  * This file is part of alarmd
00003  *
00004  * Contact Person: David Weinehall <david.weinehall@nokia.com>
00005  *
00006  * Copyright (C) 2006 Nokia Corporation
00007  * alarmd and libalarm are free software; you can redistribute them
00008  * and/or modify them under the terms of the GNU Lesser General Public
00009  * License version 2.1 as published by the Free Software Foundation.
00010  *
00011  * alarmd and libalarm are distributed in the hope that they will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this software; if not, write to the Free
00018  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
00019  * 02110-1301 USA
00020  */
00021 
00022 #ifndef _QUEUE_H_
00023 #define _QUEUE_H_
00024 
00025 #include "event.h"
00026 #include "object.h"
00027 
00028 #define ALARMD_TYPE_QUEUE (alarmd_queue_get_type())
00029 #define ALARMD_QUEUE(object) (G_TYPE_CHECK_INSTANCE_CAST((object), ALARMD_TYPE_QUEUE, AlarmdQueue))
00030 #define ALARMD_QUEUE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), ALARMD_TYPE_QUEUE, AlarmdQueueClass))
00031 #define ALARMD_IS_QUEUE(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), ALARMD_TYPE_QUEUE))
00032 #define ALARMD_IS_QUEUE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), ALARMD_TYPE_QUEUE))
00033 #define ALARMD_QUEUE_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), ALARMD_TYPE_QUEUE, AlarmdQueueClass))
00034 
00035 typedef struct _AlarmdQueue AlarmdQueue;
00036 struct _AlarmdQueue
00037 {
00038         AlarmdObject parent_instance;
00039 };
00040 
00041 typedef struct _AlarmdQueueClass AlarmdQueueClass;
00042 struct _AlarmdQueueClass
00043 {
00044         AlarmdObjectClass parent_class;
00045 
00046         glong (*add_event)(AlarmdQueue *queue, AlarmdEvent *event);
00047         gboolean (*remove_event)(AlarmdQueue *queue, glong event_id);
00048         AlarmdEvent *(*get_event)(AlarmdQueue *queue, glong event_id);
00049         glong *(*query_events)(AlarmdQueue *queue, gint64 start_time, gint64 end_time, gint32 flag_mask, gint32 flags, guint *n_events);
00050 };
00051 
00052 /**
00053  * SECTION:queue
00054  * @short_description: Object type to handle the event queue.
00055  * @see_also: #AlarmdEvent
00056  *
00057  * The #AlarmdQueue handles the #AlarmdEvent objects. It has timer plugins
00058  * that handle the events; one that can power up the device and one that
00059  * cannot. If only one timer is available, it is used for all events.
00060  **/
00061 
00062 GType alarmd_queue_get_type(void);
00063 
00064 /**
00065  * alarmd_queue_new:
00066  *
00067  * Creates new alarmd queue.
00068  * Returns: Newly created #AlarmdQueue
00069  **/
00070 AlarmdQueue *alarmd_queue_new(void);
00071 
00072 /**
00073  * alarmd_queue_add_event:
00074  * @queue: A #AlarmdQueue the @event should be added into.
00075  * @event: A #AlarmdEvent that should be added to the queue.
00076  *
00077  * Adds the @event to the @queue to be launched at apecified time.
00078  * Returns: Unique identifier for the event.
00079  **/
00080 gulong alarmd_queue_add_event(AlarmdQueue *queue, AlarmdEvent *event);
00081 
00082 /**
00083  * alarmd_queue_remove_event:
00084  * @queue: The #AlamrmdQueue from where the event should be removed from.
00085  * @event_id: The identifier for the #AlarmdEvent.
00086  *
00087  * Removes the event specified by the identifier @event_id from the @queue.
00088  * Returns: TRUE if the event was found and removed, FALSE otherwise.
00089  **/
00090 gboolean alarmd_queue_remove_event(AlarmdQueue *queue, gulong event_id);
00091 
00092 /**
00093  * alarmd_queue_query_events:
00094  * @queue: The #AlarmdQueue that should be queried.
00095  * @start_time: Events that launch avter this time should be returned.
00096  * @end_time: Events that launch before this time should be returned.
00097  * @flag_mask: Bitfield that specifies whchi fields should be checked.
00098  * @flags: The values wanted for the flags specified in @flag_mask.
00099  * @n_events: Pointer to an integer that should contain the number of events
00100  * found.
00101  *
00102  * Queries events that occurr between @start_time adn @end_time with flags
00103  * chosen with @flag_mask that have values specified in @flags.
00104  * Returns: Array of identifiers for the found events.
00105  **/
00106 glong *alarmd_queue_query_events(AlarmdQueue *queue, gint64 start_time, gint64 end_time, gint32 flag_mask, gint32 flags, guint *n_events);
00107 
00108 /**
00109  * alarmd_queue_get_event:
00110  * @queue: The #AlarmdQueue that contains the event.
00111  * @event_id: The identifier for the #AlarmdEvent.
00112  *
00113  * Finds and returns the wanted event from the queue. The event is still on
00114  * the queue.
00115  * Returns: The #AlarmdEvent with the wanted identifier or NULL if not found.
00116  **/
00117 AlarmdEvent *alarmd_queue_get_event(AlarmdQueue *queue, gulong event_id);
00118 
00119 #endif /* _QUEUE_H_ */

Generated on Thu Dec 21 18:23:30 2006 for Alarmd by  doxygen 1.4.2