MAST
function_set_base.cpp
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 // MAST includes
21 #include "base/function_set_base.h"
22 
23 
24 
26 { }
27 
28 
30 { }
31 
32 
33 
34 bool
35 MAST::FunctionSetBase::contains(const std::string& nm) const {
36 
37  std::map<std::string, MAST::FunctionBase*>::const_iterator it =
38  _properties.find(nm);
39 
40  // make sure that this funciton exists
41  return (it != _properties.end());
42 }
43 
44 
45 
46 void
48 
49  // make sure that this funciton does not already exist
50  libmesh_assert_msg(!_properties.count(f.name()),
51  "Function already exists: " + f.name());
52 
53  bool success = _properties.insert(std::pair<std::string, MAST::FunctionBase*>
54  (f.name(), &f)).second;
55  libmesh_assert(success);
56 }
57 
58 
59 
60 bool
62 
63  // check with all the properties to see if any one of them is
64  // dependent on the provided parameter, or is the parameter itself
65  std::map<std::string, MAST::FunctionBase*>::const_iterator
66  it = _properties.begin(), end = _properties.end();
67  for ( ; it!=end; it++) {
68  if (it->second->depends_on(f))
69  return true;
70  }
71 
72  // if it gets here, then there is no dependency
73  return false;
74 }
virtual ~FunctionSetBase()
destructor deletes the function pointers
void add(MAST::FunctionBase &f)
adds the function to this card and returns a reference to it.
virtual bool depends_on(const MAST::FunctionBase &f) const
returns true if the property card depends on the function f
const std::string & name() const
returns the name of this function
Definition: function_base.h:60
std::map< std::string, MAST::FunctionBase * > _properties
map of the functions in this card
bool contains(const std::string &nm) const
checks if the card contains the specified property value