LILAC
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
item.cpp
Go to the documentation of this file.
1 /*
2 Copyright (c) 2014, Sam Schetterer, Nathan Kutz, University of Washington
3 Authors: Sam Schetterer
4 All rights reserved.
5 
6 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
7 
8 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
9 
10 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
11 
12 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
13 
14 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15 
16 */
17 #include "item.h"
18 #include "../controller/controller.h"
19 #include "../rhs/rhs.h"
20 #include "../integrator/integrator.h"
21 #include "../simulation/simulation.h"
22 #include <sstream>
23 #include "comp_funcs.hpp"
24 #include "item_heads.hpp"
25 #include "types/item_factory.h"
26 #include "types/type_register.hpp"
27 #include "native_item.hpp"
28 
30 
31 constexpr char native_names::double_name[];
32 constexpr char native_names::float_name[];
33 constexpr char native_names::unsigned_name[];
34 constexpr char native_names::string_name[];
35 constexpr char native_names::integer_name[];
36 
37 template class type_register<_double>;
38 template class type_register<_float>;
39 template class type_register<string>;
40 template class type_register<integer>;
41 template class type_register<_unsigned>;
42 template class type_register<ftest1>;
43 template class type_register<ftest2>;
44 template class type_register<ftest3>;
45 
46 #ifdef ICC
47 
48 bool operator < (const std::weak_ptr<item>& a, std::weak_ptr<item>& b){
49  if(a.expired()){
50  return false;
51  }
52  if(b.expired()){
53  return true;
54  }
55  auto vala = a.lock();
56  auto valb = b.lock();
57  return vala.get() < valb.get();
58 }
59 #endif
63  holder=0;
64 }
65 void item::postprocess(input& indat){
66 }
69  _write_name=wname;
70 }
72  if(has_write_name){
73  return _write_name;
74  }
75  return _name;
76 }
77 
78 std::vector<std::string> native_item::dependencies() const{
79  return std::vector<std::string>();
80 }
82  err("Retrieve called on native item not overloading class",
83  "native_item::_retrieve", "engine/item.cpp",
84  FATAL_ERROR);
85 }
87 }
97  p.check_and_get_type(this);
98 }
108  std::string errmess = this->name();
109  errmess.append(" of type ");
110  errmess.append(this->type());
111  errmess.append(" does not support runtime updating");
112  err(errmess, "item::update", "engine/item.cpp", WARNING);
113 }
114 //item function
116 std::vector<std::string> item::dependencies()const{
117  return std::vector<std::string>();
118 }
120 void item::print() const{
121  std::cout << "A print function has not been implemented for variable type "
122  << this->type() << ", called by variable " << this->name() << std::endl;
123 }
129  _name = n;
130 }
135 const std::string& item::name()const {
136  return _name;
137 }
138 
139 //variable functions
140 
141 
147 std::shared_ptr<item> item::create(std::string name, engineimp* in){
148  item* rval=item_factory::create_item(name);
149  rval->holder = in;
150  return std::shared_ptr<item>(rval);
151 }
152