MHEG5  18.9.0
MHEG5 Documentation
mh5root.c
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright © 2014 The DTVKit Open Software Foundation Ltd (www.dtvkit.org)
3  * Copyright © 2004 Ocean Blue Software Ltd
4  * Copyright © 2000 Koninklijke Philips Electronics N.V
5  *
6  * This file is part of a DTVKit Software Component
7  * You are permitted to copy, modify or distribute this file subject to the terms
8  * of the DTVKit 1.0 Licence which can be found in licence.txt or at www.dtvkit.org
9  *
10  * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
11  * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
12  * OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
13  *
14  * If you or your organisation is not a member of DTVKit then you have access
15  * to this source code outside of the terms of the licence agreement
16  * and you are expected to delete this and any associated files immediately.
17  * Further information on DTVKit, membership and terms can be found at www.dtvkit.org
18  *******************************************************************************/
26 /*---includes for this file--------------------------------------------------*/
27 #include <string.h>
28 #include "mh5base.h" /* Base Types */
29 #include "mh5queue.h" /* Events */
30 #include "mh5object.h" /* Resolve Objects */
31 #include "mh5variable.h" /* For Actions */
32 #include "mh5final.h"
33 #include "mh5debug.h"
34 
35 
36 /*---constant definitions for this file--------------------------------------*/
37 
38 
39 /*---local typedef structs for this file-------------------------------------*/
40 
41 /*---local (static) variable declarations for this file----------------------*/
42 
43 /*---local function definitions----------------------------------------------*/
44 
45 /*---global function definitions---------------------------------------------*/
46 
47 #ifdef MH5PRINTOUT
48 
55 void MHEG5rootPrint(MHEG5Root *root, char *out)
56 {
57  MHEG5indent(out);
58  MHEG5classPrint(root->clazz, out);
59  MHEG_PRINT(out, " ");
60  MHEG5intPrint(root->id, out);
61  MHEG5newLine(out);
62  MHEG5incIndent();
63 /*
64  if (root->runningStatus)
65  {
66  MHEG5indent(out);
67  MHEG_PRINT(out,"// RunningStatus:\tTrue");
68  MHEG5newLine(out);
69  }
70  if (root->availabilityStatus)
71  {
72  MHEG5indent(out);
73  MHEG_PRINT(out,"// AvailabilityStatus:\tTrue");
74  MHEG5newLine(out);
75  }
76  */
77 }
78 
79 #endif
80 
81 
88 {
89  assert(root);
90 }
91 
100 {
101  assert(root);
102 }
103 
110 void MHEG5rootClone(MHEG5Root *destination, MHEG5Root *source)
111 {
112  assert(source);
113  assert(destination);
114 
115  destination->clazz = source->clazz;
116  destination->id = source->id;
117 }
118 
140 {
141  CALL_PRINT((">> MHEG5rootPrepare(%p)\n", root));
142 
143  assert(root);
144  /*steps 1 - 3 should have already been done */
145  /* 1. If the AvailabilityStatus attribute of the object is True, abort the behaviour. */
146  assert( !root->availabilityStatus );
147  /* Otherwise:
148  * 2. Retrieve the object from an entity outside the engine.
149  * - note - entity already retreived.
150  */
151  /* 3. Set each internal attribute of the object to its initial value. */
152 
153  /* 4. Set the AvailabilityStatus attribute to True. */
155 
156  /* 5. Generate an IsAvailable event. */
158 
159  /* 6. Perform the ContentPreparation behaviour.
160  * ... done in MHEG5ingredientPrepare()
161  */
162 
163  CALL_PRINT(("<< MHEG5rootPrepare\n"));
164 }
165 
188 {
189  assert(root);
190  /* next bit should already have been done is sub-classes
191  if (! root->availabilityStatus) {
192  MHEG5finalPrepare(root);
193  }*/
194  assert(root->availabilityStatus);
195 }
196 
211 {
212  assert(root);
213  if (!root->runningStatus)
214  return;
215  root->runningStatus = MHEG5FALSE;
216  MHEG5sendSync(root, MHEG5ISSTOPPED, 0);
217 }
218 
248 {
249  assert(root);
250  if (!root->availabilityStatus)
251  {
252  return;
253  }
254  if (root->runningStatus)
255  {
256  MHEG5finalDeactivate(root);
257  }
259  MHEG5sendSync(root, MHEG5ISDELETED, 0);
260 }
261 
262 /*
263  * Actions
264  */
265 
266 
285 {
286  MHEG5Root *statusVar = 0;
287 
288  assert(target);
289 
290  if (!params)
291  {
293  }
294  MHEG5resolveORef(params, &statusVar);
295  if (!statusVar)
296  {
298  }
299  if (statusVar->clazz != MHEG5BOOLEANVARIABLE)
300  {
301  return MHEG5ERR_WRONGPARAM;
302  }
303  if (!statusVar->runningStatus)
304  {
306  }
307 
308  if ((target) && (target->availabilityStatus))
309  {
310  ((MHEG5BooleanVariable *) statusVar)->value = MHEG5TRUE;
311  }
312  else
313  {
314  ((MHEG5BooleanVariable *) statusVar)->value = MHEG5FALSE;
315  }
316 
317  return MHEG5ERR_NOERROR;
318 }
319 
337 {
338  MHEG5Root *statusVar = 0;
339 
340  assert(target);
341 
342  if (!params)
343  {
345  }
346  MHEG5resolveORef(params, &statusVar);
347  if (!statusVar)
348  {
350  }
351 
352  if (statusVar->clazz != MHEG5BOOLEANVARIABLE)
353  {
354  return MHEG5ERR_WRONGPARAM;
355  }
356 
357  if (!((MHEG5BooleanVariable *) statusVar)->ingredient.root.runningStatus)
358  {
360  }
361 
362  ((MHEG5BooleanVariable *) statusVar)->value = target->runningStatus;
363 
364  return MHEG5ERR_NOERROR;
365 }
366 
MHEG5Bool availabilityStatus
Definition: mh5root.h:52
void MHEG5rootClone(MHEG5Root *destination, MHEG5Root *source)
Implementation of the root part of the Close action.
Definition: mh5root.c:110
Basis MHEG5 data types.
Distributor for Prepare, Destruct, Activate, Deactivate and Clone calls. Distribute the +Prepare +Des...
MHEG5ErrorCode MHEG5getAvailabilityStatus(MHEG5Root *target, MHEG5GList *params)
Implementation of the GetAvailabilityStatus action GetAvailabilityStatus (AvailabilityStatusVar) Set ...
Definition: mh5root.c:284
void MHEG5finalDeactivate(MHEG5Root *item)
Definition: mh5final.c:354
MHEG5Final clazz
Definition: mh5root.h:55
Implement the MHEG5 Variable Class 21 Variable Class Defines a variable within the context of a Group...
MHEG5ErrorCode MHEG5getRunningStatus(MHEG5Root *target, MHEG5GList *params)
Implementation of the GetRunningStatus action GetRunningStatus (RunningStatusVar) Set the Variable re...
Definition: mh5root.c:336
void MHEG5rootDestruct(MHEG5Root *root)
Implementation of the Destruction behaviour Destruction This behaviour has the basic semantics of ask...
Definition: mh5root.c:247
#define CALL_PRINT(x)
Definition: mh5debug.h:68
void MHEG5rootDeactivate(MHEG5Root *root)
Implementation of the Deactivation behaviour Deactivation This behaviour has the basic semantics of n...
Definition: mh5root.c:210
MHEG5ErrorCode
Definition: mh5base.h:222
Event handling. Implementation of a combined queue for events and actions. This is the eventsystem wh...
void MHEG5rootActivate(MHEG5Root *root)
Implementation of the Activation behaviour Activation This behaviour has the basic semantics of immed...
Definition: mh5root.c:187
#define MHEG5TRUE
Definition: mh5base.h:49
Implement functions to retrieve MHEG5objects by GroupID and ID.
Mheg5 logging and debug printing.
MHEG5Bool runningStatus
Definition: mh5root.h:51
MHEG5Int id
Definition: mh5root.h:48
void MHEG5rootFree(MHEG5Root *root)
Free off all memory associated with the specified object, including any exchanged attributes and inte...
Definition: mh5root.c:99
MHEG5GList * MHEG5resolveORef(MHEG5GList *params, MHEG5Root **object)
Definition: mh5object.c:126
void MHEG5rootPrepare(MHEG5Root *root)
Implementation of the Preparation behaviour Preparation This behaviour has the basic semantics of all...
Definition: mh5root.c:139
void MHEG5rootInit(MHEG5Root *root)
Initialise a Root object with default values.
Definition: mh5root.c:87
#define MHEG5FALSE
Definition: mh5base.h:48
void MHEG5sendSync(MHEG5Root *source, MHEG5EventType event, MHEG5Int data)
Store an event in the synchronous event queue.
Definition: mh5queue.c:1651