MAST
function_base.h
Go to the documentation of this file.
1 /*
2  * MAST: Multidisciplinary-design Adaptation and Sensitivity Toolkit
3  * Copyright (C) 2013-2019 Manav Bhatia
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 #ifndef __mast__function_base__
21 #define __mast__function_base__
22 
23 // C++ includes
24 #include <set>
25 
26 
27 // MAST includes
28 #include "base/mast_data_types.h"
29 
30 
31 namespace MAST
32 {
33 
34 
35  class FunctionBase {
36  public:
37 
41  FunctionBase(const std::string& nm ,
42  const bool is_field_func);
43 
44 
49 
50 
54  virtual ~FunctionBase() { }
55 
56 
60  const std::string& name() const {
61  return _name;
62  }
63 
64 
68  virtual bool depends_on(const MAST::FunctionBase& f) const {
69  if (_functions.count(&f)) // this function is the same
70  return true;
71 
72  // check with all functions if they are dependent
73  std::set<const MAST::FunctionBase*>::const_iterator
74  it = _functions.begin(), end = _functions.end();
75 
76  for ( ; it != end; it++)
77  if ((*it)->depends_on(f))
78  return true;
79 
80  // if it gets here, then there is no dependency
81  return false;
82  }
83 
84 
89  virtual bool is_shape_parameter() const {return _is_shape_parameter; }
90  virtual void set_as_shape_parameter(bool f) {_is_shape_parameter = f;}
91 
92 
97  virtual bool is_topology_parameter() const {return _is_topology_parameter;}
99 
100  protected:
101 
105  std::string _name;
106 
111 
114 
118  std::set<const MAST::FunctionBase*> _functions;
119  };
120 
121 }
122 
123 #endif // __mast__function_base__
virtual void set_as_topology_parameter(bool f)
Definition: function_base.h:98
std::set< const MAST::FunctionBase * > _functions
set of functions that this function depends on
virtual ~FunctionBase()
virtual destructor
Definition: function_base.h:54
std::string _name
name of this parameter
virtual bool is_shape_parameter() const
Definition: function_base.h:89
virtual bool depends_on(const MAST::FunctionBase &f) const
returns true if the function depends on the provided value
Definition: function_base.h:68
const std::string & name() const
returns the name of this function
Definition: function_base.h:60
FunctionBase(const std::string &nm, const bool is_field_func)
initializes the parameter to the given name
virtual void set_as_shape_parameter(bool f)
Definition: function_base.h:90
virtual bool is_topology_parameter() const
Definition: function_base.h:97
bool _is_field_func
flag to store the nature of field function