Ginga  0.13.6
 All Classes Namespaces Functions Variables
FormatterScheduler.h
1 /******************************************************************************
2 Este arquivo eh parte da implementacao do ambiente declarativo do middleware
3 Ginga (Ginga-NCL).
4 
5 Direitos Autorais Reservados (c) 1989-2007 PUC-Rio/Laboratorio TeleMidia
6 
7 Este programa eh software livre; voce pode redistribui-lo e/ou modificah-lo sob
8 os termos da Licenca Publica Geral GNU versao 2 conforme publicada pela Free
9 Software Foundation.
10 
11 Este programa eh distribuido na expectativa de que seja util, porem, SEM
12 NENHUMA GARANTIA; nem mesmo a garantia implicita de COMERCIABILIDADE OU
13 ADEQUACAO A UMA FINALIDADE ESPECIFICA. Consulte a Licenca Publica Geral do
14 GNU versao 2 para mais detalhes.
15 
16 Voce deve ter recebido uma copia da Licenca Publica Geral do GNU versao 2 junto
17 com este programa; se nao, escreva para a Free Software Foundation, Inc., no
18 endereco 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
19 
20 Para maiores informacoes:
21 ncl @ telemidia.puc-rio.br
22 http://www.ncl.org.br
23 http://www.ginga.org.br
24 http://www.telemidia.puc-rio.br
25 ******************************************************************************
26 This file is part of the declarative environment of middleware Ginga (Ginga-NCL)
27 
28 Copyright: 1989-2007 PUC-RIO/LABORATORIO TELEMIDIA, All Rights Reserved.
29 
30 This program is free software; you can redistribute it and/or modify it under
31 the terms of the GNU General Public License version 2 as published by
32 the Free Software Foundation.
33 
34 This program is distributed in the hope that it will be useful, but WITHOUT ANY
35 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
36 PARTICULAR PURPOSE. See the GNU General Public License version 2 for more
37 details.
38 
39 You should have received a copy of the GNU General Public License version 2
40 along with this program; if not, write to the Free Software
41 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
42 
43 For further information contact:
44 ncl @ telemidia.puc-rio.br
45 http://www.ncl.org.br
46 http://www.ginga.org.br
47 http://www.telemidia.puc-rio.br
48 *******************************************************************************/
49 
50 #ifndef _FORMATTERSCHEDULER_H_
51 #define _FORMATTERSCHEDULER_H_
52 
53 extern "C" {
54 #include <assert.h>
55 }
56 
57 #include "contextmanager/IContextListener.h"
58 using namespace ::br::pucrio::telemidia::ginga::core::contextmanager;
59 
60 #include "model/ExecutionObject.h"
61 #include "model/NodeNesting.h"
62 #include "model/CompositeExecutionObject.h"
63 using namespace ::br::pucrio::telemidia::ginga::ncl::model::components;
64 
65 #include "model/ExecutionObjectSwitch.h"
66 #include "model/SwitchEvent.h"
67 using namespace ::br::pucrio::telemidia::ginga::ncl::model::switches;
68 
69 #include "model/AttributionEvent.h"
70 #include "model/IEventListener.h"
71 #include "model/FormatterEvent.h"
72 #include "model/PresentationEvent.h"
73 using namespace ::br::pucrio::telemidia::ginga::ncl::model::event;
74 
75 #include "model/LinkAssignmentAction.h"
76 #include "model/LinkSimpleAction.h"
77 using namespace ::br::pucrio::telemidia::ginga::ncl::model::link;
78 
79 #include "model/FormatterLayout.h"
80 using namespace ::br::pucrio::telemidia::ginga::ncl::model::presentation;
81 
82 #include "adaptation/context/RuleAdapter.h"
83 #include "adaptation/context/IPresentationContext.h"
84 using namespace ::br::pucrio::telemidia::ginga::ncl::adaptation::context;
85 
86 #include "adapters/application/ApplicationPlayerAdapter.h"
87 using namespace ::br::pucrio::telemidia::ginga::ncl::adapters::application;
88 
89 #include "adapters/FormatterPlayerAdapter.h"
90 #include "adapters/PlayerAdapterManager.h"
91 using namespace ::br::pucrio::telemidia::ginga::ncl::adapters;
92 
93 #include "ncl/connectors/SimpleAction.h"
94 #include "ncl/connectors/EventUtil.h"
95 using namespace ::br::pucrio::telemidia::ncl::connectors;
96 
97 #include "ncl/components/CompositeNode.h"
98 #include "ncl/components/ContentNode.h"
99 #include "ncl/components/Node.h"
100 #include "ncl/components/NodeEntity.h"
101 using namespace ::br::pucrio::telemidia::ncl::components;
102 
103 #include "ncl/interfaces/Port.h"
104 #include "ncl/interfaces/Anchor.h"
105 #include "ncl/interfaces/ContentAnchor.h"
106 #include "ncl/interfaces/PropertyAnchor.h"
107 #include "ncl/interfaces/SwitchPort.h"
108 using namespace ::br::pucrio::telemidia::ncl::interfaces;
109 
110 #include "ncl/reuse/ReferNode.h"
111 using namespace ::br::pucrio::telemidia::ncl::reuse;
112 
113 #include "focus/FormatterFocusManager.h"
114 using namespace ::br::pucrio::telemidia::ginga::ncl::focus;
115 
116 #include "multidevice/IFormatterMultiDevice.h"
117 using namespace ::br::pucrio::telemidia::ginga::ncl::multidevice;
118 
119 #include "IFormatterSchedulerListener.h"
120 #include "emconverter/ObjectCreationForbiddenException.h"
121 
122 #include "animation/AnimationController.h"
123 using namespace ::br::pucrio::telemidia::ginga::ncl::animation;
124 
125 #include <iostream>
126 #include <string>
127 #include <map>
128 #include <vector>
129 using namespace std;
130 
131 namespace br {
132 namespace pucrio {
133 namespace telemidia {
134 namespace ginga {
135 namespace ncl {
137  public ILinkActionListener,
138  public IFormatterScheduler,
139  public IEventListener,
140  public IContextListener {
141 
142  private:
143  RuleAdapter* ruleAdapter;
144  PlayerAdapterManager* playerManager;
145  IPresentationContext* presContext;
146  IFormatterMultiDevice* multiDevPres;
147  FormatterFocusManager* focusManager;
148 
149  void* compiler; //FormatterConverter*
150  vector<IFormatterSchedulerListener*> schedulerListeners;
151  vector<FormatterEvent*> documentEvents;
152  map<FormatterEvent*, bool> documentStatus;
153  set<void*> actions;
154 
155  bool running;
156 
157  set<string> typeSet;
158  pthread_mutex_t mutexD;
159  pthread_mutex_t mutexActions;
160 
161  set<FormatterEvent*> listening;
162  pthread_mutex_t lMutex;
163 
164  public:
166  PlayerAdapterManager* playerManager,
167  RuleAdapter* ruleAdapter,
168  IFormatterMultiDevice* multiDevice,
169  void* compiler); //FormatterConverter
170 
171  virtual ~FormatterScheduler();
172 
173  void addAction(void* action);
174  void removeAction(void* action);
175 
176  bool setKeyHandler(bool isHandler);
177  //void setStandByState(bool standBy);
178  FormatterFocusManager* getFocusManager();
179  void* getFormatterLayout(void* descriptor, void* object);
180 
181  private:
182  bool isDocumentRunning(FormatterEvent* event);
183 
184  void setTimeBaseObject(
185  ExecutionObject* object,
186  FormatterPlayerAdapter* objectPlayer, string nodeId);
187 
188  static void printAction(
189  string action,
190  LinkCondition* condition,
191  LinkSimpleAction* linkAction);
192 
193  public:
194  void scheduleAction(void* condition, void* action);
195 
196  private:
197  void runAction(LinkCondition* condition, LinkSimpleAction* action);
198 
199  void runAction(
200  FormatterEvent* event,
201  LinkCondition* condition,
202  LinkSimpleAction* action);
203 
204  void runActionOverProperty(
205  FormatterEvent* event,
206  LinkSimpleAction* action);
207 
208  void runActionOverApplicationObject(
209  ApplicationExecutionObject* executionObject,
210  FormatterEvent* event,
211  FormatterPlayerAdapter* player,
212  LinkSimpleAction* action);
213 
214  void runActionOverComposition(
215  CompositeExecutionObject* compositeObject,
216  LinkSimpleAction* action);
217 
218  void runActionOverSwitch(
219  ExecutionObjectSwitch* switchObject,
220  SwitchEvent* event,
221  LinkSimpleAction* action);
222 
223  void runSwitchEvent(
224  ExecutionObjectSwitch* switchObject,
225  SwitchEvent* switchEvent,
226  ExecutionObject* selectedObject,
227  LinkSimpleAction* action);
228 
229  string solveImplicitRefAssessment(
230  string propValue, AttributionEvent* event);
231 
232  public:
233  void startEvent(FormatterEvent* event);
234  void stopEvent(FormatterEvent* event);
235  void pauseEvent(FormatterEvent* event);
236  void resumeEvent(FormatterEvent* event);
237 
238  private:
239  void initializeDefaultSettings();
240  void initializeDocumentSettings(Node* node);
241 
242  public:
243  void startDocument(
244  FormatterEvent* documentEvent,
245  vector<FormatterEvent*>* entryEvents);
246 
247  private:
248  void removeDocument(FormatterEvent* documentEvent);
249 
250  public:
251  void stopDocument(FormatterEvent* documentEvent);
252  void pauseDocument(FormatterEvent* documentEvent);
253  void resumeDocument(FormatterEvent* documentEvent);
254  void stopAllDocuments();
255  void pauseAllDocuments();
256  void resumeAllDocuments();
257  void eventStateChanged(
258  void* someEvent, short transition, short previousState);
259 
260  short getPriorityType();
261  void addSchedulerListener(IFormatterSchedulerListener* listener);
262  void removeSchedulerListener(IFormatterSchedulerListener* listener);
263  void receiveGlobalAttribution(string propertyName, string value);
264  };
265 }
266 }
267 }
268 }
269 }
270 
271 #endif //_FORMATTERSCHEDULER_H_
Definition: IFormatterSchedulerListener.h:61
Definition: IFormatterScheduler.h:60
Definition: FormatterScheduler.h:136