Template object for Event.

This commit is contained in:
Marcelo Roberto Jimenez 2010-09-11 18:06:59 -03:00
parent 9c7bdcffb4
commit 43621874e9
2 changed files with 9 additions and 151 deletions

View File

@ -1,5 +1,4 @@
#ifndef EVENT_H
#define EVENT_H
@ -9,53 +8,19 @@
*
* \brief UpnpEvent object declararion.
*
* Returned along with a \b UPNP_EVENT_RECEIVED callback.
*
* \author Marcelo Roberto Jimenez
*/
#define CLASS UpnpEvent
/*! Returned along with a \b UPNP_EVENT_RECEIVED callback. */
typedef struct s_UpnpEvent UpnpEvent;
#define EXPAND_CLASS_MEMBERS(CLASS) \
EXPAND_CLASS_MEMBER_INT(CLASS, EventKey, int) \
EXPAND_CLASS_MEMBER_INT(CLASS, ChangedVariables, IXML_Document *) \
EXPAND_CLASS_MEMBER_STRING(CLASS, SID) \
#include "ixml.h" /* for IXML_Document */
#include "UpnpGlobal.h" /* for EXPORT_SPEC */
#include "UpnpString.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*! Constructor */
EXPORT_SPEC UpnpEvent *UpnpEvent_new();
/*! Destructor */
EXPORT_SPEC void UpnpEvent_delete(UpnpEvent *p);
/*! Copy Constructor */
EXPORT_SPEC UpnpEvent *UpnpEvent_dup(const UpnpEvent *p);
/*! Assignment operator */
EXPORT_SPEC void UpnpEvent_assign(UpnpEvent *p, const UpnpEvent *q);
/*! The event sequence number. */
EXPORT_SPEC int UpnpEvent_get_EventKey(const UpnpEvent *p);
EXPORT_SPEC void UpnpEvent_set_EventKey(UpnpEvent *p, int n);
/*! The DOM tree representing the changes generating the event. */
EXPORT_SPEC IXML_Document *UpnpEvent_get_ChangedVariables(const UpnpEvent *p);
EXPORT_SPEC void UpnpEvent_set_ChangedVariables(UpnpEvent *p, IXML_Document *d);
/*! The subscription ID for this subscription. */
EXPORT_SPEC const UpnpString *UpnpEvent_get_SID(const UpnpEvent *p);
EXPORT_SPEC const char *UpnpEvent_get_SID_cstr(const UpnpEvent *p);
EXPORT_SPEC void UpnpEvent_set_SID(UpnpEvent *p, const UpnpString *s);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#include "TemplateInclude.h"
#endif /* EVENT_H */

View File

@ -1,5 +1,4 @@
/*!
* \file
*
@ -8,114 +7,8 @@
* \author Marcelo Roberto Jimenez
*/
#include "config.h"
#define TEMPLATE_GENERATE_SOURCE
#include "Event.h"
#include <stdlib.h> /* for calloc(), free() */
struct SUpnpEvent
{
int m_eventKey;
IXML_Document *m_changedVariables;
UpnpString *m_SID;
};
UpnpEvent *UpnpEvent_new()
{
struct SUpnpEvent *p = calloc(1, sizeof (struct SUpnpEvent));
#if 0
p->m_eventKey = 0;
p->m_changedVariables = NULL;
#endif
p->m_SID = UpnpString_new();
return (UpnpEvent *)p;
}
void UpnpEvent_delete(UpnpEvent *p)
{
struct SUpnpEvent *q = (struct SUpnpEvent *)p;
if (!q) return;
q->m_eventKey = 0;
q->m_changedVariables = NULL;
UpnpString_delete(q->m_SID);
q->m_SID = NULL;
free(p);
}
UpnpEvent *UpnpEvent_dup(const UpnpEvent *p)
{
UpnpEvent *q = UpnpEvent_new();
UpnpEvent_assign(q, p);
return q;
}
void UpnpEvent_assign(UpnpEvent *p, const UpnpEvent *q)
{
if (p != q) {
UpnpEvent_set_EventKey(p, UpnpEvent_get_EventKey(q));
UpnpEvent_set_ChangedVariables(p, UpnpEvent_get_ChangedVariables(q));
UpnpEvent_set_SID(p, UpnpEvent_get_SID(q));
}
}
int UpnpEvent_get_EventKey(const UpnpEvent *p)
{
return ((struct SUpnpEvent *)p)->m_eventKey;
}
void UpnpEvent_set_EventKey(UpnpEvent *p, int n)
{
((struct SUpnpEvent *)p)->m_eventKey = n;
}
IXML_Document *UpnpEvent_get_ChangedVariables(const UpnpEvent *p)
{
return ((struct SUpnpEvent *)p)->m_changedVariables;
}
void UpnpEvent_set_ChangedVariables(UpnpEvent *p, IXML_Document *d)
{
ixmlDocument_free(((struct SUpnpEvent *)p)->m_changedVariables);
((struct SUpnpEvent *)p)->m_changedVariables = d;
}
const UpnpString *UpnpEvent_get_SID(const UpnpEvent *p)
{
return ((struct SUpnpEvent *)p)->m_SID;
}
const char *UpnpEvent_get_SID_cstr(const UpnpEvent *p)
{
return UpnpString_get_String(UpnpEvent_get_SID(p));
}
void UpnpEvent_set_SID(UpnpEvent *p, const UpnpString *s)
{
UpnpString_delete(((struct SUpnpEvent *)p)->m_SID);
((struct SUpnpEvent *)p)->m_SID = UpnpString_dup(s);
}