14e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park/** @addtogroup MCD_MCDIMPL_DAEMON_DEV
24e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @{
34e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * @file
44e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
54e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * MobiCore Notification Queue handling.
64e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
74e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * <!-- Copyright Giesecke & Devrient GmbH 2009 - 2012 -->
87b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim *
94e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * Redistribution and use in source and binary forms, with or without
104e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * modification, are permitted provided that the following conditions
114e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * are met:
124e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * 1. Redistributions of source code must retain the above copyright
134e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *    notice, this list of conditions and the following disclaimer.
144e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * 2. Redistributions in binary form must reproduce the above copyright
154e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *    notice, this list of conditions and the following disclaimer in the
164e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *    documentation and/or other materials provided with the distribution.
174e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * 3. The name of the author may not be used to endorse or promote
184e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *    products derived from this software without specific prior
194e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *    written permission.
204e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park *
214e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
224e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
234e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
244e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
254e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
264e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
274e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
284e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
294e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
304e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
314e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
324e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park */
334e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park#ifndef NOTIFICATIONQUEUE_H_
344e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park#define NOTIFICATIONQUEUE_H_
354e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
364e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park#include <inttypes.h> //C99 data
374e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park#include "Mci/mcinq.h"
384e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park#include "CMutex.h"
394e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
404e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
417b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kimclass NotificationQueue
427b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim{
434e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
444e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Parkpublic:
454e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
467b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim    /** NQ Constructor, initializes the NQ component.
477b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim     *
487b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim     * makes the given queue object usable with the queue<Command> type of functions
497b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim     *
507b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim     * @param in queue to initialize
517b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim     * @param out beginning of queue header
527b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim     * @param queueSize Size of the queue
537b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim     */
547b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim    NotificationQueue(
557b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim        notificationQueue_t *in,
567b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim        notificationQueue_t *out,
577b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim        uint32_t size
587b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim    );
594e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
607b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim    /** Places an element to the outgoing queue.
617b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim     *
627b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim     * @param notification Data to be placed in queue.
637b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim     */
647b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim    void putNotification(
657b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim        notification_t *notification
667b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim    );
674e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
687b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim    /** Retrieves the first element from the queue.
697b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim     *
707b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim     * @return first notification Queue element.
717b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim     * @return NULL if the queue is empty.
727b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim     */
737b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim    notification_t *getNotification(
747b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim        void
757b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim    );
764e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
774e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Parkprivate:
784e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
797b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim    notificationQueue_t *in;
807b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim    notificationQueue_t *out;
817b143edf281bed18c8ebd0733465f3af5af327ebJungtae Kim    CMutex mutex;
824e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
834e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park};
844e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
854e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park#endif /* NOTIFICATIONQUEUE_H_ */
864e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park
874e9e8c9c0169b40318386436d762c3d73cf4c328DongJin Park/** @} */
88