Ginga  0.13.6
 All Classes Namespaces Functions Variables
FormatterConverter.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 FORMATTERCONVERTER_H_
51 #define FORMATTERCONVERTER_H_
52 
53 #include "ncl/switches/SwitchNode.h"
54 using namespace ::br::pucrio::telemidia::ncl::switches;
55 
56 #include "ncl/interfaces/PropertyAnchor.h"
57 #include "ncl/interfaces/ContentAnchor.h"
58 #include "ncl/interfaces/LambdaAnchor.h"
59 #include "ncl/interfaces/SwitchPort.h"
60 #include "ncl/interfaces/Port.h"
61 #include "ncl/interfaces/InterfacePoint.h"
62 using namespace ::br::pucrio::telemidia::ncl::interfaces;
63 
64 #include "ncl/components/CompositeNode.h"
65 #include "ncl/components/ContextNode.h"
66 #include "ncl/components/ContentNode.h"
67 #include "ncl/components/Node.h"
68 #include "ncl/components/NodeEntity.h"
69 using namespace ::br::pucrio::telemidia::ncl::components;
70 
71 #include "ncl/connectors/EventUtil.h"
72 using namespace ::br::pucrio::telemidia::ncl::connectors;
73 
74 #include "ncl/descriptor/GenericDescriptor.h"
75 using namespace ::br::pucrio::telemidia::ncl::descriptor;
76 
77 #include "ncl/link/Bind.h"
78 #include "ncl/link/CausalLink.h"
79 #include "ncl/link/Link.h"
80 using namespace ::br::pucrio::telemidia::ncl::link;
81 
82 #include "ncl/reuse/ReferNode.h"
83 using namespace ::br::pucrio::telemidia::ncl::reuse;
84 
85 #include "../model/ExecutionObjectSwitch.h"
86 #include "../model/SwitchEvent.h"
87 using namespace ::br::pucrio::telemidia::ginga::ncl::model::switches;
88 
89 #include "../model/AttributionEvent.h"
90 #include "../model/PresentationEvent.h"
91 #include "../model/SelectionEvent.h"
92 #include "../model/IEventListener.h"
93 #include "../model/FormatterEvent.h"
94 #include "../model/PresentationEvent.h"
95 using namespace ::br::pucrio::telemidia::ginga::ncl::model::event;
96 
97 #include "../model/FormatterCausalLink.h"
98 #include "../model/FormatterLink.h"
99 #include "../model/LinkAction.h"
100 #include "../model/LinkCompoundAction.h"
101 #include "../model/LinkSimpleAction.h"
102 #include "../model/ILinkActionListener.h"
103 using namespace ::br::pucrio::telemidia::ginga::ncl::model::link;
104 
105 #include "../model/CascadingDescriptor.h"
106 #include "../model/FormatterLayout.h"
107 using namespace ::br::pucrio::telemidia::ginga::ncl::model::presentation;
108 
109 #include "../model/CompositeExecutionObject.h"
110 #include "../model/ApplicationExecutionObject.h"
111 #include "../model/ExecutionObject.h"
112 #include "../model/NodeNesting.h"
113 using namespace ::br::pucrio::telemidia::ginga::ncl::model::components;
114 
115 #include "../adaptation/context/RuleAdapter.h"
116 using namespace ::br::pucrio::telemidia::ginga::ncl::adaptation::context;
117 
118 #include "../adapters/PlayerAdapterManager.h"
119 using namespace ::br::pucrio::telemidia::ginga::ncl::adapters;
120 
121 #include "../IFormatterScheduler.h"
122 using namespace ::br::pucrio::telemidia::ginga::ncl;
123 
124 #include "ObjectCreationForbiddenException.h"
125 
126 #include <map>
127 #include <vector>
128 #include <set>
129 #include <string>
130 using namespace std;
131 
132 namespace br {
133 namespace pucrio {
134 namespace telemidia {
135 namespace ginga {
136 namespace ncl {
137 namespace emconverter {
138  class FormatterConverter : public IEventListener {
139  private:
140  int depthLevel;
141  static int dummyCount;
142  map<string, ExecutionObject*> executionObjects;
143  set<FormatterEvent*> listening;
144  set<ExecutionObject*> settingObjects;
145  void* linkCompiler; //FormatterLinkConverter*
146  IFormatterScheduler* scheduler;
147  ILinkActionListener* actionListener;
148  RuleAdapter* ruleAdapter;
149  pthread_mutex_t objectsMutex;
150  pthread_mutex_t lMutex;
151  bool handling;
152 
153  public:
154  FormatterConverter(RuleAdapter* ruleAdapter);
155  virtual ~FormatterConverter();
156 
157  void executionObjectReleased(string objectId);
158  set<ExecutionObject*>* getRunningObjects();
159  void setHandlingStatus(bool hanling);
160  ExecutionObject* getObjectFromNodeId(string id);
161 
162  void setScheduler(IFormatterScheduler* scheduler);
163  void setLinkActionListener(ILinkActionListener* actionListener);
164 
165  void setDepthLevel(int level);
166  int getDepthLevel();
167  void checkGradSameInstance(
168  set<ReferNode*>* gradSame, ExecutionObject* object);
169 
170  CompositeExecutionObject* addSameInstance(
171  ExecutionObject* executionObject,
172  ReferNode* referNode);
173 
174  private:
175  void addExecutionObject(
176  ExecutionObject* executionObject,
177  CompositeExecutionObject* parentObject,
178  int depthLevel);
179 
180  public:
181  void compileExecutionObjectLinks(
182  ExecutionObject* executionObject, int depthLevel);
183 
184  ExecutionObject* getExecutionObjectFromPerspective(
185  NodeNesting* perspective,
186  GenericDescriptor* descriptor,
187  int depthLevel) throw(ObjectCreationForbiddenException*);
188 
189  set<ExecutionObject*>* getSettingNodeObjects();
190 
191  private:
192  CompositeExecutionObject* getParentExecutionObject(
193  NodeNesting* perspective,
194  int depthLevel) throw(ObjectCreationForbiddenException*);
195 
196  public:
197  FormatterEvent* getEvent(
198  ExecutionObject* executionObject,
199  InterfacePoint* interfacePoint,
200  int ncmEventType,
201  string key);
202 
203  private:
204  void createMultichannelObject(
205  CompositeExecutionObject* compositeObject, int depthLevel);
206 
207  ExecutionObject* createExecutionObject(
208  string id,
209  NodeNesting* perspective,
210  CascadingDescriptor* descriptor,
211  int depthLevel);
212 
213  static bool hasDescriptorPropName(string name);
214 
215  static Descriptor* createDummyDescriptor(Node* node);
216  static CascadingDescriptor* createDummyCascadingDescriptor(
217  Node* node);
218 
219  static CascadingDescriptor* checkCascadingDescriptor(Node* node);
220  static CascadingDescriptor* checkContextCascadingDescriptor(
221  NodeNesting* nodePerspective,
222  CascadingDescriptor* cascadingDescriptor,
223  Node* ncmNode);
224 
225  public:
226  static CascadingDescriptor* getCascadingDescriptor(
227  NodeNesting* nodePerspective,
228  GenericDescriptor* descriptor);
229 
230  private:
231  void processLink(
232  Link* ncmLink,
233  Node* dataObject,
234  ExecutionObject* executionObject,
235  CompositeExecutionObject* parentObject);
236 
237  public:
238  void compileExecutionObjectLinks(
239  ExecutionObject* executionObject,
240  Node* dataObject,
241  CompositeExecutionObject* parentObject,
242  int depthLevel);
243 
244  private:
245  void setActionListener(LinkAction* action);
246 
247  public:
248  ExecutionObject* processExecutionObjectSwitch(
249  ExecutionObjectSwitch* switchObject);
250 
251  private:
252  void resolveSwitchEvents(
253  ExecutionObjectSwitch* switchObject, int depthLevel);
254 
255  FormatterEvent* insertNode(
256  NodeNesting* perspective,
257  InterfacePoint* interfacePoint,
258  GenericDescriptor* descriptor);
259 
260  public:
261  FormatterEvent* insertContext(
262  NodeNesting* contextPerspective, Port* port);
263 
264  bool removeExecutionObject(
265  ExecutionObject* executionObject, ReferNode* referNode);
266 
267  bool removeExecutionObject(ExecutionObject* executionObject);
268 
269  private:
270  bool ntsRemoveExecutionObject(ExecutionObject* executionObject);
271 
272  public:
273  ExecutionObject* hasExecutionObject(
274  Node* node, GenericDescriptor* descriptor);
275 
276  FormatterCausalLink* addCausalLink(
277  ContextNode* context, CausalLink* link);
278 
279  void eventStateChanged(
280  void* someEvent, short transition, short previousState);
281 
282  short getPriorityType();
283  void reset();
284  };
285 }
286 }
287 }
288 }
289 }
290 }
291 
292 #endif /*FORMATTERCONVERTER_H_*/
Definition: IFormatterScheduler.h:60