xc
TransfCooHandler.h
1 //----------------------------------------------------------------------------
2 // XC program; finite element analysis code
3 // for structural analysis and design.
4 //
5 // Copyright (C) Luis Claudio Pérez Tato
6 //
7 // This program derives from OpenSees <http://opensees.berkeley.edu>
8 // developed by the «Pacific earthquake engineering research center».
9 //
10 // Except for the restrictions that may arise from the copyright
11 // of the original program (see copyright_opensees.txt)
12 // XC is free software: you can redistribute it and/or modify
13 // it under the terms of the GNU General Public License as published by
14 // the Free Software Foundation, either version 3 of the License, or
15 // (at your option) any later version.
16 //
17 // This software is distributed in the hope that it will be useful, but
18 // WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 //
23 // You should have received a copy of the GNU General Public License
24 // along with this program.
25 // If not, see <http://www.gnu.org/licenses/>.
26 //----------------------------------------------------------------------------
27 //TransfCooHandler.h
28 
29 #ifndef TRANSFCOOLOADER_H
30 #define TRANSFCOOLOADER_H
31 
32 #include "PrepHandler.h"
33 #include <map>
34 
35 namespace XC {
36 class Domain;
37 class CrdTransf;
38 class LinearCrdTransf2d;
39 class LinearCrdTransf3d;
40 class PDeltaCrdTransf2d;
41 class PDeltaCrdTransf3d;
42 class CorotCrdTransf2d;
43 class CorotCrdTransf3d;
44 
45 
50  {
51  public:
52  typedef std::map<std::string,CrdTransf *> map_transfcoo;
53  typedef map_transfcoo::const_iterator const_iterator;
54  typedef map_transfcoo::iterator iterator;
55  private:
56  map_transfcoo transfcoo;
57  int tag_trf;
58  protected:
59  void free_mem(void);
62  public:
64  const map_transfcoo &Map(void) const;
65 
66  template<class T>
67  T *newCrdTransf(const std::string &);
68  LinearCrdTransf2d *newLinearCrdTransf2d(const std::string &);
69  LinearCrdTransf3d *newLinearCrdTransf3d(const std::string &);
70  PDeltaCrdTransf2d *newPDeltaCrdTransf2d(const std::string &);
71  PDeltaCrdTransf3d *newPDeltaCrdTransf3d(const std::string &);
72  CorotCrdTransf2d *newCorotCrdTransf2d(const std::string &);
73  CorotCrdTransf3d *newCorotCrdTransf3d(const std::string &);
74 
75  const_iterator begin(void) const;
76  const_iterator end(void) const;
77  iterator begin(void);
78  iterator end(void);
79  const_iterator find(const std::string &str) const;
80  iterator find(const std::string &str);
81  CrdTransf *find_ptr(const std::string &str);
82  CrdTransf *find_ptr(const int &tag);
83  const CrdTransf *find_ptr(const std::string &str) const;
84  const CrdTransf *find_ptr(const int &tag) const;
85  std::string getName(const int &tag) const;
86 
87  ~TransfCooHandler(void);
88 
89  void clearAll(void);
90  };
91 
92 template<class T>
93 T *TransfCooHandler::newCrdTransf(const std::string &trfName)
94  {
95  T *retval= nullptr;
96  CrdTransf *ptr= find_ptr(trfName);
97  if(ptr)
98  {
99  std::cerr << getClassName() << "::" << __FUNCTION__
100  << "transformation: '" << trfName
101  << "' aready exists. I do nothing." << std::endl;
102  retval= dynamic_cast<T *>(ptr);
103  }
104  else
105  {
106  retval= new T(tag_trf++);
107  assert(retval);
108  retval->set_owner(this);
109  transfcoo[trfName]= retval;
110  }
111  return retval;
112  }
113 } // end of XC namespace
114 
115 #endif
PDeltaCrdTransf3d provides the abstraction of a linear transformation for a spatial frame between the...
Definition: PDeltaCrdTransf3d.h:73
~TransfCooHandler(void)
Destructor.
Definition: TransfCooHandler.cc:64
Finite element model generation tools.
Definition: Preprocessor.h:58
CrdTransf provides the abstraction of a frame coordinate transformation.
Definition: CrdTransf.h:87
Linear coordinate transformation.
Definition: LinearCrdTransf3d.h:74
Base class for the preprocessor objects that create model entities: nodes, elements, loads, etc.
Definition: PrepHandler.h:46
const_iterator find(const std::string &str) const
Returns an iterator to the transformation with the name being passed as parameter.
Definition: TransfCooHandler.cc:109
PDeltaCrdTransf3d * newPDeltaCrdTransf3d(const std::string &)
Creates a new pdelta 3D coordinate transformation.
Definition: TransfCooHandler.cc:80
CorotCrdTransf3d * newCorotCrdTransf3d(const std::string &)
Creates a new corotationa 3D coordinate transformation.
Definition: TransfCooHandler.cc:88
Coordinate transformation corrotacional en 3d.
Definition: CorotCrdTransf2d.h:71
LinearCrdTransf2d * newLinearCrdTransf2d(const std::string &)
Creates a new linear 2D coordinate transformation.
Definition: TransfCooHandler.cc:68
const_iterator end(void) const
Returns an iterator apuntando después del final de la lista.
Definition: TransfCooHandler.cc:99
void clearAll(void)
Deletes all members.
Definition: TransfCooHandler.cc:182
CorotCrdTransf2d * newCorotCrdTransf2d(const std::string &)
Creates a new corotationa 2D coordinate transformation.
Definition: TransfCooHandler.cc:84
CrdTransf * find_ptr(const std::string &str)
Returns a pointer to the transformation with the name being passed as parameter (returns nullptr if n...
Definition: TransfCooHandler.cc:117
PDeltaCrdTransf2d provides the abstraction of a linear transformation for a spatial frame between the...
Definition: PDeltaCrdTransf2d.h:76
const_iterator begin(void) const
Returns an iterator which points to principio de la lista.
Definition: TransfCooHandler.cc:96
Manager for the creation/deletion of coordinate transformations.
Definition: TransfCooHandler.h:49
TransfCooHandler(const TransfCooHandler &)
Copy constructor.
Definition: TransfCooHandler.cc:51
PDeltaCrdTransf2d * newPDeltaCrdTransf2d(const std::string &)
Creates a new pdelta 2D coordinate transformation.
Definition: TransfCooHandler.cc:76
std::string getName(const int &tag) const
Returns the name that corresponds to the coordinate transformation tag being passed as parameter...
Definition: TransfCooHandler.cc:168
LinearCrdTransf3d * newLinearCrdTransf3d(const std::string &)
Creates a new linear 3D coordinate transformation.
Definition: TransfCooHandler.cc:72
Open source finite element program for structural analysis.
Definition: ContinuaReprComponent.h:34
LinearCrdTransf2d provides the abstraction of a linear transformation for a spatial frame between the...
Definition: LinearCrdTransf2d.h:74
TransfCooHandler & operator=(const TransfCooHandler &)
Assignment operator.
Definition: TransfCooHandler.cc:56
void free_mem(void)
Frees memory.
Definition: TransfCooHandler.cc:39
Coordinate transformation corrotacional en 3d.
Definition: CorotCrdTransf3d.h:73
const map_transfcoo & Map(void) const
Returns a reference to the coordinate transformation map (container).
Definition: TransfCooHandler.cc:92