[2] | 1 | // %flair:license{
|
---|
[15] | 2 | // This file is part of the Flair framework distributed under the
|
---|
| 3 | // CECILL-C License, Version 1.0.
|
---|
[2] | 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 |
|
---|
| 22 | using std::string;
|
---|
| 23 | using namespace flair::core;
|
---|
| 24 |
|
---|
[15] | 25 | io_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;
|
---|
[2] | 33 | }
|
---|
| 34 |
|
---|
| 35 | io_data_impl::~io_data_impl() {}
|
---|
| 36 |
|
---|
[15] | 37 | void io_data_impl::AppendLogDescription(string description,
|
---|
| 38 | DataType const &datatype) {
|
---|
| 39 | description += " (" + datatype.GetDescription() + ")";
|
---|
| 40 | descriptors.push_back(description);
|
---|
[2] | 41 | }
|
---|
| 42 |
|
---|
[15] | 43 | void io_data_impl::WriteLogDescriptor(std::fstream &desc_file, int *index) {
|
---|
[122] | 44 | if(descriptors.size()==0) self->Warn("AppendLogDescription was not called for this object.\n");
|
---|
[15] | 45 | for (size_t i = 0; i < descriptors.size(); i++) {
|
---|
| 46 | desc_file << (*index)++ << ": " << self->ObjectName() << " - "
|
---|
| 47 | << descriptors.at(i) << "\n";
|
---|
| 48 | }
|
---|
[2] | 49 | }
|
---|
| 50 |
|
---|
| 51 | void io_data_impl::PrintLogDescriptor(void) {
|
---|
[15] | 52 | for (size_t i = 0; i < descriptors.size(); i++) {
|
---|
| 53 | Printf(" %s\n", descriptors.at(i).c_str());
|
---|
| 54 | }
|
---|
[2] | 55 | }
|
---|
| 56 |
|
---|
| 57 | void io_data_impl::Circle(void) {
|
---|
[15] | 58 | if (n > 1) {
|
---|
| 59 | self->GetMutex();
|
---|
[2] | 60 |
|
---|
[15] | 61 | void *tmp = *self->Prev(n - 1)->pimpl_->circle_ptr;
|
---|
[2] | 62 |
|
---|
[15] | 63 | for (int i = 0; i < n - 1; i++) {
|
---|
| 64 | // printf("%i\n",i);
|
---|
| 65 | *(self->Prev(n - 1 - i)->pimpl_->circle_ptr) =
|
---|
| 66 | *(self->Prev(n - 2 - i)->pimpl_->circle_ptr);
|
---|
| 67 | self->Prev(n - 1 - i)->pimpl_->is_consistent =
|
---|
| 68 | self->Prev(n - 2 - i)->pimpl_->is_consistent;
|
---|
| 69 | self->Prev(n - 1 - i)->pimpl_->time = self->Prev(n - 2 - i)->pimpl_->time;
|
---|
[2] | 70 | }
|
---|
[15] | 71 | *circle_ptr = tmp;
|
---|
| 72 | is_consistent = false;
|
---|
| 73 | self->ReleaseMutex();
|
---|
| 74 | }
|
---|
[2] | 75 | }
|
---|
| 76 |
|
---|
[15] | 77 | bool io_data_impl::IsConsistent(void) { return is_consistent; }
|
---|
[2] | 78 |
|
---|
[15] | 79 | void io_data_impl::SetConsistent(bool status) { is_consistent = status; }
|
---|