XIOS  1.0
Xml I/O Server
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Définitions de type Énumérations Valeurs énumérées Amis Macros
extract_axis.cpp
Aller à la documentation de ce fichier.
1 #include "extract_axis.hpp"
2 #include "type.hpp"
3 
4 namespace xios {
5 
7 
9  : CObjectTemplate<CExtractAxis>(), CExtractAxisAttributes(), CTransformation<CAxis>()
10  { /* Ne rien faire de plus */ }
11 
13  : CObjectTemplate<CExtractAxis>(id), CExtractAxisAttributes(), CTransformation<CAxis>()
14  { /* Ne rien faire de plus */ }
15 
17  {}
18 
20  {
21  CExtractAxis* extractAxis = CExtractAxisGroup::get("extract_axis_definition")->createChild(id);
22  if (node) extractAxis->parse(*node);
23  return static_cast<CTransformation<CAxis>*>(extractAxis);
24  }
25 
27  {
29  }
30 
32 
33  //----------------------------------------------------------------
34 
35  StdString CExtractAxis::GetName(void) { return StdString("extract_axis"); }
36  StdString CExtractAxis::GetDefName(void) { return StdString("extract_axis"); }
38 
40  {
41  int axisIBegin, axisNi, axisGlobalSize;
42  int begin, end, n;
43 
44  axisIBegin = axisDest->begin.getValue();
45  axisNi = axisDest->n.getValue();
46  axisGlobalSize = axisDest->n_glo.getValue();
47 
48  bool extractByIndex = !this->index.isEmpty() && (0 != this->index.numElements());
49 
50  if (extractByIndex)
51  {
52  begin = min(this->index);
53  end = max(this->index);
54  n = end - begin + 1;
55  }
56  else
57  {
58  begin = (this->begin.isEmpty()) ? 0 : this->begin.getValue();
59  n = (this->n.isEmpty()) ? axisGlobalSize : this->n.getValue();
60  end = begin+n-1;
61  }
62 
63  if (begin < 0 || begin > axisGlobalSize - 1 || end < 0 || end > axisGlobalSize - 1
64  || n < 1 || n > axisGlobalSize || begin > end)
65  ERROR("CExtractAxis::checkValid(CAxis* axisDest)",
66  << "One or more attributes among 'begin' (" << begin << "), 'end' (" << end << "), 'n' (" << n << ") "
67  << "of axis transformation [ id = '" << axisDest->getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] are not well specified");
68 
69  if (extractByIndex && (!this->begin.isEmpty() || !this->n.isEmpty()))
70  ERROR("CExtractAxis::checkValid(CAxis* axisDest)",
71  << "Only one type of extract is accepted. Define extract by index with global_extract_index or define extract with begin and n. "
72  << "Axis transformation [ id = '" << axisDest->getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] are not well specified");
73 
74  this->begin.setValue(begin);
75  this->n.setValue(n);
76 
77  }
78 
79 }
CExtractAxis(void)
Constructeurs ///.
Definition: extract_axis.cpp:8
virtual ~CExtractAxis(void)
Destructeur ///.
static bool _dummyRegistered
static StdString GetName(void)
Accesseurs statiques ///.
static StdString GetDefName(void)
std::string StdString
Definition: xios_spl.hpp:48
#define xios(arg)
const StdString & getId(void) const
Accesseurs ///.
Definition: object.cpp:26
static ENodeType GetType(void)
CATCH CScalarAlgorithmReduceScalar::CScalarAlgorithmReduceScalar(CScalar *scalarDestination, CScalar *scalarSource, CReduceScalarToScalar *algo ERROR)("CScalarAlgorithmReduceScalar::CScalarAlgorithmReduceScalar(CScalar* scalarDestination, CScalar* scalarSource, CReduceScalarToScalar* algo)",<< "Operation must be defined."<< "Scalar source "<< scalarSource->getId()<< std::endl<< "Scalar destination "<< scalarDestination->getId())
////////////////////// Déclarations ////////////////////// ///
virtual void parse(xml::CXMLNode &node)
static bool registerTrans()
enum xios::_node_type ENodeType
////////////////////// Définitions ////////////////////// ///
virtual void checkValid(CAxis *axisDest)
static bool registerTransformation(ETranformationType transType, CreateTransformationCallBack createFn)
static CTransformation< CAxis > * create(const StdString &id, xml::CXMLNode *node)
static StdString & GetCurrentContextId(void)
Accesseurs ///.