source: XMLIO_V2/dev/dev_rv/src/functor.cpp @ 143

Last change on this file since 143 was 141, checked in by hozdoba, 13 years ago

Mise à jour depuis un autre dépôt

File size: 3.0 KB
Line 
1#include "functor.hpp"
2
3namespace xmlioserver
4{
5   namespace func
6   {
7      /// ////////////////////// Définitions ////////////////////// ///
8
9      CFunctor::CFunctor(const StdString & id, ARRAY(double, 1) doutput,
10                         const CFunData & data, CFuncType type)
11         : SuperClass(id)
12         , doutput(doutput), size()
13         , data(data), type(type)
14      { this->resize(size); }
15
16      CFunctor::CFunctor(const StdString & id, DoubleArray doutput,
17                         const std::vector<size_t> size,
18                         const CFunData & data, CFuncType type)
19         : SuperClass(id)
20         , doutput(doutput), size(size)
21         , data(data), type(type)
22      { this->resize(size); }
23
24      CFunctor::~CFunctor(void)
25      { /* Ne rien faire de plus */ }
26
27      //---------------------------------------------------------------
28
29      const CFunctor::CFunData  & CFunctor::getData(void) const
30      { return (this->data); }
31
32      CFunctor::CFuncType CFunctor::getType(void) const
33      { return (this->type); }
34
35      ARRAY(double, 1) CFunctor::getDataOutput(void) const
36      { return (this->doutput); }
37
38      const std::vector<size_t> & CFunctor::getShape(void) const
39      { return (this->size); }
40
41      size_t CFunctor::getSize(void) const
42      { return (this->doutput->size()); }
43
44      //---------------------------------------------------------------
45
46      void CFunctor::resize(size_t x, size_t y, size_t z)
47      {
48         this->size.clear();
49         this->size.push_back(x);
50         if (y != 1) this->size.push_back(y);
51         if (z != 1) this->size.push_back(z);
52         this->doutput->resize(boost::extents[x * y * z]);
53      }
54
55      void CFunctor::resize(const std::vector<size_t> & sizes)
56      {
57         size_t newsize = 1;
58         this->size.clear();
59         BOOST_FOREACH(size_t size, sizes)
60         { newsize *= size; this->size.push_back(size); }
61         this->doutput->resize(boost::extents[newsize]);
62      }
63
64      //---------------------------------------------------------------
65
66      StdString CFunctor::toString(void) const
67      {
68         ERROR("CFunctor::toString()", << "Not implemented yet !");
69         return (SuperClass::getId());
70      }
71
72      void CFunctor::fromString(const StdString & str)
73      {
74         ERROR("CFunctor::fromString(str)",
75                << "[ str = " << str << "] Not implemented yet !");
76      }
77
78      //---------------------------------------------------------------
79
80      ARRAY(double, 1) CFunctor::operator ()(const ARRAY(double, 1) dinput)
81      {
82         if (dinput->size() != this->doutput->size())
83            ERROR("CFunctor::operator ()(dinput)",
84                   << "[ input size = "  << dinput->size()
85                   << ", output size = " << this->doutput->size() << " ]"
86                   << " size of input array !=  size of output array !");
87         this->apply(dinput, this->doutput, this->size, this->data);
88         return (this->doutput);
89      }
90
91      //---------------------------------------------------------------
92
93   } // namespace func
94} // namespace xmlioserver
Note: See TracBrowser for help on using the repository browser.