source: flair-src/trunk/lib/FlairCore/src/io_data_impl.cpp@ 223

Last change on this file since 223 was 223, checked in by Sanahuja Guillaume, 4 years ago

add delta time to io_data

File size: 2.3 KB
Line 
1// %flair:license{
2// This file is part of the Flair framework distributed under the
3// CECILL-C License, Version 1.0.
4// %flair:license}
5// created: 2012/03/21
6// filename: io_data_impl.cpp
7//
8// author: Guillaume Sanahuja
9// Copyright Heudiasyc UMR UTC/CNRS 7253
10//
11// version: $Id: $
12//
13// purpose: classe définissant une donnée générique
14//
15//
16/*********************************************************************/
17
18#include "io_data.h"
19#include "io_data_impl.h"
20#include <fstream>
21
22using std::string;
23using namespace flair::core;
24
25io_data_impl::io_data_impl(io_data *self, int n) {
26 this->self = self;
27 this->n = n;
28 if (n < 1)
29 self->Err("n doit être >0\n");
30 size = 0;
31 is_consistent = false;
32 circle_ptr = NULL;
33 deltaTime=TIME_INFINITE;//init
34 time=TIME_INFINITE;//init
35}
36
37io_data_impl::~io_data_impl() {}
38
39void io_data_impl::AppendLogDescription(string description,
40 DataType const &datatype) {
41 description += " (" + datatype.GetDescription() + ")";
42 descriptors.push_back(description);
43}
44
45void io_data_impl::WriteLogDescriptor(std::fstream &desc_file, int *index) {
46 if(descriptors.size()==0) self->Warn("AppendLogDescription was not called for this object.\n");
47 for (size_t i = 0; i < descriptors.size(); i++) {
48 desc_file << (*index)++ << ": " << self->ObjectName() << " - "
49 << descriptors.at(i) << "\n";
50 }
51}
52
53void io_data_impl::PrintLogDescriptor(void) {
54 for (size_t i = 0; i < descriptors.size(); i++) {
55 Printf(" %s\n", descriptors.at(i).c_str());
56 }
57}
58
59void io_data_impl::Circle(void) {
60 if (n > 1) {
61 self->GetMutex();
62
63 void *tmp = *self->Prev(n - 1)->pimpl_->circle_ptr;
64
65 for (int i = 0; i < n - 1; i++) {
66 // printf("%i\n",i);
67 *(self->Prev(n - 1 - i)->pimpl_->circle_ptr) =
68 *(self->Prev(n - 2 - i)->pimpl_->circle_ptr);
69 self->Prev(n - 1 - i)->pimpl_->is_consistent =
70 self->Prev(n - 2 - i)->pimpl_->is_consistent;
71 self->Prev(n - 1 - i)->pimpl_->time = self->Prev(n - 2 - i)->pimpl_->time;
72 }
73 *circle_ptr = tmp;
74 is_consistent = false;
75 self->ReleaseMutex();
76 }
77}
78
79bool io_data_impl::IsConsistent(void) { return is_consistent; }
80
81void io_data_impl::SetConsistent(bool status) { is_consistent = status; }
Note: See TracBrowser for help on using the repository browser.