source: flair-dev/trunk/include/FlairSimulator/DiscreteTimeVariable.h@ 12

Last change on this file since 12 was 9, checked in by Sanahuja Guillaume, 9 years ago

lic

File size: 1.4 KB
RevLine 
[9]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}
[8]5// created: 2014/03/30
6// filename: DiscreteTimeVariable.cpp
7//
8// author: Guillaume Sanahuja
9// Copyright Heudiasyc UMR UTC/CNRS 7253
10//
11// version: $Id: $
12//
13// purpose: base class for discrete time variable
14//
15/*********************************************************************/
16
17#ifndef DISCRETETIMEVARIABLE_H
18#define DISCRETETIMEVARIABLE_H
19
20#include <stdlib.h>
21
22namespace flair
23{
24namespace simulator
25{
26 template <typename T,size_t size>
27 class DiscreteTimeVariable
28 {
29 public:
30 DiscreteTimeVariable(){};
31 ~DiscreteTimeVariable(){};
32 T& operator[](ssize_t idx)
33 {
34 if(idx>0) idx=0;
35 if(idx<(ssize_t)(-size+1)) idx=-size+1;
36 return array[-idx];
37 }
38 const T&operator[](ssize_t idx) const
39 {
40 return const_cast<T&>(*this)[idx];
41 };
42 void Update(void)
43 {
44 for(int i=size-1;i>0;i--)
45 {
46 array[i]=array[i-1];
47 }
48 }
49
50 private:
51 T array[size];
52
53 };
54} // end namespace simulator
55} // end namespace flair
56#endif // DISCRETETIMEVARIABLE_H
Note: See TracBrowser for help on using the repository browser.