SelectField.hpp
1 /*---------------------------------------------------------------------------*\
2  *
3  * mimmo
4  *
5  * Copyright (C) 2015-2021 OPTIMAD engineering Srl
6  *
7  * -------------------------------------------------------------------------
8  * License
9  * This file is part of mimmo.
10  *
11  * mimmo is free software: you can redistribute it and/or modify it
12  * under the terms of the GNU Lesser General Public License v3 (LGPL)
13  * as published by the Free Software Foundation.
14  *
15  * mimmo is distributed in the hope that it will be useful, but WITHOUT
16  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18  * License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with mimmo. If not, see <http://www.gnu.org/licenses/>.
22  *
23 \*---------------------------------------------------------------------------*/
24 #ifndef __SelectFieldS_HPP__
25 #define __SelectFieldS_HPP__
26 
27 #include "BaseManipulation.hpp"
28 
29 namespace mimmo{
30 
35 enum class SelectType{
36  GEOMETRY = 0,
38  NAME = 1,
39  MAPPING = 2
41 };
42 
98 protected:
100  double m_tol;
101  std::string m_fieldname;
105 public:
106  SelectField();
107  virtual ~SelectField();
108 
109  SelectField(const SelectField & other);
110 
111  void buildPorts();
112 
113  void setMode(SelectType mode);
114  void setMode(int mode);
115  void setFieldName(std::string fieldname);
116  void setTolerance(double tol);
117 
118  std::string getFieldName();
119 
120  void clear();
121  void execute();
122 
123  virtual void absorbSectionXML(const bitpit::Config::Section & slotXML, std::string name="");
124  virtual void flushSectionXML(bitpit::Config::Section & slotXML, std::string name="");
125 
126 protected:
127  void swap(SelectField &) noexcept;
128 private:
133  virtual bool mSelect() = 0;
134 };
135 
193 private:
194  MPVLocation m_loc;
195  std::vector<dmpvector1D> m_fields;
196  dmpvector1D m_result;
198 public:
200  SelectScalarField(const bitpit::Config::Section & rootXMl);
201  SelectScalarField(const SelectScalarField & other);
202  virtual ~SelectScalarField();
203 
204  void buildPorts();
206  void setFields(std::vector<dmpvector1D *> fields);
207  void addField(dmpvector1D *field);
208 
209  void clear();
210 
211  void plotOptionalResults();
212 
213  virtual void absorbSectionXML(const bitpit::Config::Section & slotXML, std::string name="");
214  virtual void flushSectionXML(bitpit::Config::Section & slotXML, std::string name="");
215 
216 protected:
217  void swap(SelectScalarField &) noexcept;
218 
219 private:
220  bool mSelect();
221 
222 };
223 
224 
225 
283 private:
284  MPVLocation m_loc;
285  std::vector<dmpvecarr3E> m_fields;
286  dmpvecarr3E m_result;
288 public:
289 
291  SelectVectorField(const bitpit::Config::Section & rootXMl);
292  SelectVectorField(const SelectVectorField & other);
293  virtual ~SelectVectorField();
294 
295  void buildPorts();
297  void setFields(std::vector<dmpvecarr3E *> fields);
298  void addField(dmpvecarr3E *field);
299 
300  void clear();
301 
302  void plotOptionalResults();
303 
304  virtual void absorbSectionXML(const bitpit::Config::Section & slotXML, std::string name="");
305  virtual void flushSectionXML(bitpit::Config::Section & slotXML, std::string name="");
306 
307 protected:
308  void swap(SelectVectorField &) noexcept;
309 
310 private:
311  bool mSelect();
312 
313 };
314 
315 
316 
374 private:
375  MPVLocation m_loc;
376  std::vector<MimmoPiercedVector<long> > m_fields;
377  MimmoPiercedVector<long> m_result;
379 public:
380 
382  SelectLongField(const bitpit::Config::Section & rootXMl);
383  SelectLongField(const SelectLongField & other);
384  virtual ~SelectLongField();
385 
386  void buildPorts();
388  void setFields(std::vector<MimmoPiercedVector<long> *> fields);
389  void addField(MimmoPiercedVector<long> *field);
390 
391  void clear();
392 
393  void plotOptionalResults();
394 
395  virtual void absorbSectionXML(const bitpit::Config::Section & slotXML, std::string name="");
396  virtual void flushSectionXML(bitpit::Config::Section & slotXML, std::string name="");
397 
398 protected:
399  void swap(SelectLongField &) noexcept;
400 
401 private:
402  bool mSelect();
403 
404 };
405 
406 
407 
465 private:
466  MPVLocation m_loc;
467  std::vector<MimmoPiercedVector<std::string>> m_fields;
470 public:
471 
473  SelectStringField(const bitpit::Config::Section & rootXMl);
474  SelectStringField(const SelectStringField & other);
475  virtual ~SelectStringField();
476 
477  void buildPorts();
479  void setFields(std::vector<MimmoPiercedVector<std::string> *> fields);
481 
482  void clear();
483 
484  void plotOptionalResults();
485 
486  virtual void absorbSectionXML(const bitpit::Config::Section & slotXML, std::string name="");
487  virtual void flushSectionXML(bitpit::Config::Section & slotXML, std::string name="");
488 
489 protected:
490  void swap(SelectStringField &) noexcept;
491 
492 private:
493  bool mSelect();
494 
495 };
496 
497 
498 
499 REGISTER_PORT(M_GEOM, MC_SCALAR, MD_MIMMO_, __SelectFieldS_HPP__)
500 REGISTER_PORT(M_NAME, MC_SCALAR, MD_STRING, __SelectFieldS_HPP__)
501 REGISTER_PORT(M_SCALARFIELD, MC_SCALAR, MD_MPVECFLOAT_, __SelectFieldS_HPP__)
503 REGISTER_PORT(M_LONGFIELD, MC_SCALAR, MD_MPVECLONG_, __SelectFieldS_HPP__)
504 REGISTER_PORT(M_STRINGFIELD, MC_SCALAR, MD_MPVECSTRING_, __SelectFieldS_HPP__)
507 REGISTER_PORT(M_VECLONGFIELDS, MC_VECTOR, MD_MPVECLONG_, __SelectFieldS_HPP__)
509 
510 REGISTER(BaseManipulation, SelectScalarField, "mimmo.SelectScalarField")
514 };
515 
516 #endif /* __SelectFieldS_HPP__ */
void addField(MimmoPiercedVector< std::string > *field)
void swap(SelectLongField &) noexcept
#define M_LONGFIELD
virtual ~SelectField()
Definition: SelectField.cpp:40
void setFields(std::vector< MimmoPiercedVector< long > * > fields)
void swap(SelectField &) noexcept
Definition: SelectField.cpp:56
void addField(dmpvector1D *field)
#define M_GEOM
void swap(SelectVectorField &) noexcept
#define M_VECVECTORFIELDS
void setMode(SelectType mode)
Definition: SelectField.cpp:93
MPVLocation
Define data location for the MimmoPiercedVector field.
MimmoPiercedVector< std::string > * getSelectedField()
SelectLongField is specialized derived class of SelectField to Select a scalar field of long data.
virtual void flushSectionXML(bitpit::Config::Section &slotXML, std::string name="")
void setFieldName(std::string fieldname)
Definition: SelectField.cpp:84
void addField(dmpvecarr3E *field)
void swap(SelectScalarField &) noexcept
BaseManipulation is the base class of any manipulation object of the library.
SelectVectorField is specialized derived class of SelectField to Select a vector field.
SelectScalarField is specialized derived class of SelectField to Select a scalar field.
virtual void absorbSectionXML(const bitpit::Config::Section &slotXML, std::string name="")
MimmoPiercedVector is the basic data container for mimmo library.
#define M_VECTORFIELD
SelectStringField(MPVLocation loc=MPVLocation::POINT)
virtual void absorbSectionXML(const bitpit::Config::Section &slotXML, std::string name="")
#define M_VECLONGFIELDS
std::string getFieldName()
#define M_STRINGFIELD
#define MC_SCALAR
#define MD_MPVECARR3FLOAT_
#define REGISTER_PORT(Name, Container, Datatype, ManipBlock)
virtual void absorbSectionXML(const bitpit::Config::Section &slotXML, std::string name="")
virtual void flushSectionXML(bitpit::Config::Section &slotXML, std::string name="")
virtual void flushSectionXML(bitpit::Config::Section &slotXML, std::string name="")
#define MD_STRING
MimmoPiercedVector< long > * getSelectedField()
SelectType
Methods available for selecting a field.
Definition: SelectField.hpp:35
#define MC_VECTOR
SelectVectorField(MPVLocation loc=MPVLocation::POINT)
std::string m_fieldname
void addField(MimmoPiercedVector< long > *field)
SelectStringField is specialized derived class of SelectField to Select a scalar field of string data...
void setFields(std::vector< MimmoPiercedVector< std::string > * > fields)
#define MD_MIMMO_
#define M_NAME
SelectScalarField(MPVLocation loc=MPVLocation::POINT)
virtual void absorbSectionXML(const bitpit::Config::Section &slotXML, std::string name="")
#define MD_MPVECFLOAT_
virtual void flushSectionXML(bitpit::Config::Section &slotXML, std::string name="")
#define M_SCALARFIELD
#define M_VECSCALARFIELDS
void swap(SelectStringField &) noexcept
SelectField is an abstract executable block class capable of Selecting a field from a list of fields.
Definition: SelectField.hpp:97
#define MD_MPVECLONG_
SelectLongField(MPVLocation loc=MPVLocation::POINT)
#define MD_MPVECSTRING_
#define M_VECSTRINGFIELDS
void setFields(std::vector< dmpvecarr3E * > fields)
void setTolerance(double tol)
#define REGISTER(Base, Derived, name)
Definition: factory.hpp:206
virtual void flushSectionXML(bitpit::Config::Section &slotXML, std::string name="")
virtual void absorbSectionXML(const bitpit::Config::Section &slotXML, std::string name="")
void setFields(std::vector< dmpvector1D * > fields)