Ginga  0.13.6
 All Classes Namespaces Functions Variables
ExecutionObject.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 _EXECUTIONOBJECT_H_
51 #define _EXECUTIONOBJECT_H_
52 
53 #include "util/functions.h"
54 using namespace ::br::pucrio::telemidia::util;
55 
56 #include "system/thread/Thread.h"
57 using namespace ::br::pucrio::telemidia::ginga::core::system::thread;
58 
59 #include "mb/interface/CodeMap.h"
60 using namespace ::br::pucrio::telemidia::ginga::core::mb;
61 
62 #include "player/IPlayer.h"
63 using namespace ::br::pucrio::telemidia::ginga::core::player;
64 
65 #include "ncl/animation/Animation.h"
66 using namespace ::br::pucrio::telemidia::ncl::animation;
67 
68 #include "ncl/descriptor/GenericDescriptor.h"
69 using namespace ::br::pucrio::telemidia::ncl::descriptor;
70 
71 #include "ncl/components/ReferenceContent.h"
72 using namespace ::br::pucrio::telemidia::ncl::components;
73 
74 #include "ncl/interfaces/LabeledAnchor.h"
75 #include "ncl/interfaces/LambdaAnchor.h"
76 #include "ncl/interfaces/IntervalAnchor.h"
77 #include "ncl/interfaces/PropertyAnchor.h"
78 using namespace ::br::pucrio::telemidia::ncl::interfaces;
79 
80 #include "ncl/layout/LayoutRegion.h"
81 using namespace ::br::pucrio::telemidia::ncl::layout;
82 
83 #include "ncl/connectors/EventUtil.h"
84 using namespace ::br::pucrio::telemidia::ncl::connectors;
85 
86 #include "FormatterEvent.h"
87 #include "PresentationEvent.h"
88 #include "SelectionEvent.h"
89 #include "AttributionEvent.h"
90 using namespace ::br::pucrio::telemidia::ginga::ncl::model::event;
91 
92 #include "BeginEventTransition.h"
93 #include "EndEventTransition.h"
94 #include "EventTransition.h"
95 #include "EventTransitionManager.h"
96 #include "TransitionDispatcher.h"
97 using namespace ::br::pucrio::telemidia::ginga::ncl::model::event::transition;
98 
99 #include "CascadingDescriptor.h"
100 #include "FormatterRegion.h"
101 using namespace ::br::pucrio::telemidia::ginga::ncl::model::presentation;
102 
103 #include "LinkSimpleAction.h"
104 #include "ILinkActionListener.h"
105 using namespace ::br::pucrio::telemidia::ginga::ncl::model::link;
106 
107 #include "NodeNesting.h"
108 
109 #include <pthread.h>
110 #include <map>
111 #include <vector>
112 #include <string>
113 #include <iostream>
114 #include <set>
115 using namespace std;
116 
117 namespace br {
118 namespace pucrio {
119 namespace telemidia {
120 namespace ginga {
121 namespace ncl {
122 namespace model {
123 namespace components {
125  protected:
126  string id;
127  Node* dataObject;
128  CascadingDescriptor* descriptor;
129  double offsetTime;
130  double startTime;
131  PresentationEvent* wholeContent;
132 
133  set<string> typeSet;
134  pthread_mutex_t mutex;
135  pthread_mutex_t mutexEvent;
136  pthread_mutex_t mutexParentTable;
137 
138  ILinkActionListener* seListener;
139 
140  bool isLocked;
141  bool deleting;
142  bool isHandler;
143  bool isHandling;
144 
145  private:
146  map<Node*, Node*> nodeParentTable;
147 
148  protected:
149  map<Node*, void*> parentTable; //CompositionExecutionObject
150  bool visible;
151 
152  private:
153  bool isItCompiled;
154 
155  protected:
156  map<string, FormatterEvent*> events;
157  vector<PresentationEvent*> presEvents;
158  set<SelectionEvent*> selectionEvents;
159  vector<FormatterEvent*> otherEvents;
160  int pauseCount;
161  FormatterEvent* mainEvent;
162  EventTransitionManager* transMan;
163 
164  private:
165  static set<ExecutionObject*> objects;
166  static bool initMutex;
167  static pthread_mutex_t _objMutex;
168 
169  protected:
170  static void addInstance(ExecutionObject* object);
171  static bool removeInstance(ExecutionObject* object);
172 
173  public:
175  string id,
176  Node* node,
177  bool handling,
178  ILinkActionListener* seListener);
179 
181  string id,
182  Node* node,
183  GenericDescriptor* descriptor,
184  bool handling,
185  ILinkActionListener* seListener);
186 
188  string id,
189  Node* node,
190  CascadingDescriptor* descriptor,
191  bool handling,
192  ILinkActionListener* seListener);
193 
194  virtual ~ExecutionObject();
195 
196  static bool hasInstance(ExecutionObject* object, bool eraseFromList);
197 
198  private:
199  void initializeExecutionObject(
200  string id,
201  Node* node,
202  CascadingDescriptor* descriptor,
203  bool handling,
204  ILinkActionListener* seListener);
205 
206  protected:
207  void destroyEvents();
208  virtual void unsetParentsAsListeners();
209  virtual void removeParentListenersFromEvent(FormatterEvent* event);
210 
211  public:
212  virtual bool isSleeping();
213  virtual bool isPaused();
214  bool instanceOf(string s);
215  int compareToUsingId(ExecutionObject* object);
216  Node* getDataObject();
217  CascadingDescriptor* getDescriptor();
218  string getId();
219  void* getParentObject(); //CompositeExecutionObject
220  void* getParentObject(Node* node); //CompositeExecutionObject
221  void addParentObject(void* parentObject, Node* parentNode);
222  void addParentObject(Node* node, void* parentObject, Node* parentNode);
223  virtual void removeParentObject(Node* parentNode, void* parentObject);
224 
225  void setDescriptor(CascadingDescriptor* cascadingDescriptor);
226  void setDescriptor(GenericDescriptor* descriptor);
227  string toString();
228  virtual bool addEvent(FormatterEvent* event);
229  void addPresentationEvent(PresentationEvent* event);
230  int compareTo(ExecutionObject* object);
231  int compareToUsingStartTime(ExecutionObject* object);
232  bool containsEvent(FormatterEvent* event);
233  FormatterEvent* getEventFromAnchorId(string anchorId);
234 
235  public:
236  FormatterEvent* getEvent(string id);
237  vector<FormatterEvent*>* getEvents();
238  bool hasSampleEvents();
239  set<AnchorEvent*>* getSampleEvents();
240  double getExpectedStartTime();
241  PresentationEvent* getWholeContentPresentationEvent();
242  void setStartTime(double t);
243  void updateEventDurations();
244  void updateEventDuration(PresentationEvent* event);
245  bool removeEvent(FormatterEvent* event);
246  bool isCompiled();
247  void setCompiled(bool status);
248  void removeNode(Node* node);
249  vector<Node*>* getNodes();
250  vector<Anchor*>* getNCMAnchors();
251  PropertyAnchor* getNCMProperty(string propertyName);
252  NodeNesting* getNodePerspective();
253  NodeNesting* getNodePerspective(Node* node);
254  vector<ExecutionObject*>* getObjectPerspective();
255  vector<ExecutionObject*>* getObjectPerspective(Node* node);
256  vector<Node*>* getParentNodes();
257  FormatterEvent* getMainEvent();
258  virtual bool prepare(FormatterEvent* event, double offsetTime);
259  virtual bool start();
260 
261  void timeBaseNaturalEnd(int64_t timeValue, short int transType);
262  void updateTransitionTable(
263  double value, IPlayer* player, short int transType);
264 
265  void resetTransitionEvents(short int transType);
266  void prepareTransitionEvents(short int transType, double startTime);
267  set<double>* getTransitionsValues(short int transType);
268  virtual EventTransition* getNextTransition();
269  virtual bool stop();
270  virtual bool abort();
271  virtual bool pause();
272  virtual bool resume();
273  virtual bool setPropertyValue(
274  AttributionEvent* event, string value);
275 
276  virtual string getPropertyValue(string propName);
277 
278  virtual bool unprepare();
279 
280  void setHandling(bool isHandling);
281  void setHandler(bool isHandler);
282  bool selectionEvent(int keyCode, double currentTime);
283  set<int>* getInputEvents();
284 
285  protected:
286  bool lock();
287  bool unlock();
288 
289  private:
290  void lockEvents();
291  void unlockEvents();
292 
293  void lockParentTable();
294  void unlockParentTable();
295  };
296 }
297 }
298 }
299 }
300 }
301 }
302 }
303 
304 #endif //_EXECUTIONOBJECT_H_