sample.cpp
1 /*
2  name: sample/sample.cpp
3 
4  This file is part of ARCS - Augmented Reality Component System
5  (version 2-current), written by Jean-Yves Didier
6  for IBISC Laboratory (http://www.ibisc.univ-evry.fr)
7 
8  Copyright (C) 2013 Université d'Evry-Val d'Essonne
9 
10  This program is free software: you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation, either version 2 of the License, or
13  (at your option) any later version.
14 
15  This program is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with this program. If not, see <http://www.gnu.org/licenses/>.
22 
23 
24  Please send bugreports with examples or suggestions to
25  jean-yves.didier__at__ibisc.univ-evry.fr
26 */
27 
28 
29 #include "sample.h"
30 #include <iostream>
31 
32 
33 #ifdef WIN32
34 #include <windows.h>
35 #else
36 #include <unistd.h>
37 #endif
38 
40 {
41  for (int i = 0; i < n ; i++)
42  {
43  std::cout << "[Loop] Emitting iteration " << i << std::endl;
44  emit newIteration(i);
45  }
46  emit sendToken("end");
47 }
48 
49 
51 {
52  std::cout << "[DInt] Received integer " << i << std::endl;
53 }
54 
55 
57 {
58  std::cout << "[DInt] Recieved integer array " << std::endl;
59  for (int i = 0 ; i < ia.getSize() ; i++)
60  {
61  std::cout << "\t" << ia[i] << std::endl;
62  }
63 
64 
65 }
66 
67 void StackExploder::tic()
68 {
69  calls++;
70  if (calls % 1000 == 0)
71  std::cout << "[Stack] " << calls << " calls performed." << std::endl;
72  emit toc();
73 }
74 
75 
76 ComponentNester::ComponentNester(QObject* parent) : QObject(parent)
77 {
78  nestedComponent = 0;
79 }
80 
81 void ComponentNester::setComponent(QObject* cmp)
82 {
83  std::cout << "[NCmp] Nesting component" << std::endl;
84  Loop* loop = dynamic_cast<Loop*>(cmp);
85 
86  if (loop == 0)
87  return ;
88 
89  nestedComponent = loop;
90 
91  std::cout << "[NCmp] Nesting succeeded" << std::endl;
92 }
93 
94 void ComponentNester::setIterations(int n)
95 {
96  std::cout << "[NCmp] Nesting iteration calls" << std::endl;
97  if (nestedComponent == 0)
98  return;
99 
100  nestedComponent->setIterations(n);
101  std::cout << "[NCmp] Iterations transmitted" << std::endl;
102 }
103 
104 void Sleeper::setSeconds(int n)
105 {
106  std::cout << "[Slp] I will sleep " << n << " seconds." << std::endl;
107  for (int i=0; i < n ; i++)
108  {
109  std::cout << "[Slp] " << qPrintable(text) << " is sleeping "
110  << i << std::endl;
111 #ifdef WIN32
112  Sleep(1000);
113 #else
114  sleep(1);
115 #endif
116 
117 
118  }
119  emit sendToken("end");
120 }
void display(int i)
Displays in the console the number passed as a parameter.
Definition: sample.cpp:50
void setIterations(int n)
Gives the number of iterations.
Definition: sample.cpp:39
Template class to implement arrays.
Definition: arcsarray.h:50
This class is a loop sending as much iterations as needed.
Definition: sample.h:44
void newIteration(int i)
Sends an iteration.
void sendToken(QString s)
Sends a token once the number of iterations have been reached.