Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OpenModels/src/N_DEV_RegisterDevices.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 // Copyright Notice
3 //
4 // Copyright 2002 Sandia Corporation. Under the terms
5 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S.
6 // Government retains certain rights in this software.
7 //
8 // Xyce(TM) Parallel Electrical Simulator
9 // Copyright (C) 2002-2011 Sandia Corporation
10 //
11 // This program is free software: you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation, either version 3 of the License, or
14 // (at your option) any later version.
15 //
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 //-----------------------------------------------------------------------------
24 
25 //-------------------------------------------------------------------------
26 // Filename : $RCSfile: N_DEV_RegisterDevices.C,v $
27 //
28 // Purpose :
29 //
30 // Special Notes :
31 //
32 // Creator : David Baur
33 //
34 // Creation Date : 3/15/2013
35 //
36 // Revision Information:
37 // ---------------------
38 //
39 // Revision Number: $Revision: 1.17 $
40 //
41 // Revision Date : $Date: 2014/02/11 22:33:45 $
42 //
43 // Current Owner : $Author: tvrusso $
44 //-------------------------------------------------------------------------
45 
46 #include <Xyce_config.h>
47 
48 #ifdef HAVE_DLFCN_H
49 #include <dlfcn.h>
50 #endif
51 
52 #include <N_DEV_RegisterDevices.h>
53 
54 #include <N_DEV_2DPDE.h>
55 #include <N_DEV_ACC.h>
56 #include <N_DEV_ADC.h>
57 #include <N_DEV_BJT.h>
58 #include <N_DEV_Bsrc.h>
59 #include <N_DEV_Capacitor.h>
60 #include <N_DEV_DAC.h>
61 #include <N_DEV_Digital.h>
62 #include <N_DEV_Diode.h>
63 #include <N_DEV_DiodePDE.h>
64 #include <N_DEV_Inductor.h>
65 #include <N_DEV_ISRC.h>
66 #include <N_DEV_JFET.h>
67 #include <N_DEV_LTRA.h>
68 #include <N_DEV_MESFET.h>
69 #include <N_DEV_MOSFET1.h>
70 #include <N_DEV_MOSFET2.h>
71 #include <N_DEV_MOSFET3.h>
72 #include <N_DEV_MOSFET6.h>
73 #include <N_DEV_MOSFET_B3.h>
74 #include <N_DEV_MOSFET_B3SOI.h>
75 #include <N_DEV_MOSFET_B4.h>
76 #include <N_DEV_MutIndLin.h>
77 #include <N_DEV_MutIndNonLin2.h>
78 #include <N_DEV_MutIndNonLin.h>
79 #include <N_DEV_OpAmp.h>
80 #include <N_DEV_Resistor3.h>
81 #include <N_DEV_Resistor.h>
82 #include <N_DEV_ThermalResistor.h>
83 #include <N_DEV_ROM.h>
84 #include <N_DEV_RxnSet.h>
85 #include <N_DEV_SW.h>
86 #include <N_DEV_TRA.h>
87 #include <N_DEV_VCCS.h>
88 #include <N_DEV_Vcvs.h>
89 #include <N_DEV_VDMOS.h>
90 #include <N_DEV_Vsrc.h>
91 #include <N_DEV_Xygra.h>
92 
93 #include <N_DEV_Neuron.h>
94 #include <N_DEV_Neuron2.h>
95 #include <N_DEV_Neuron3.h>
96 #include <N_DEV_Neuron4.h>
97 #include <N_DEV_Neuron5.h>
98 #include <N_DEV_Neuron6.h>
99 #include <N_DEV_Neuron7.h>
100 #include <N_DEV_Neuron8.h>
101 #include <N_DEV_Neuron9.h>
102 #include <N_DEV_NeuronPop1.h>
103 #include <N_DEV_Synapse.h>
104 #include <N_DEV_Synapse2.h>
105 #include <N_DEV_Synapse3.h>
106 #include <N_DEV_Synapse4.h>
107 
108 #include <N_DEV_ADMSHBT_X.h>
109 #include <N_DEV_ADMSPSP103VA.h>
110 #include <N_DEV_ADMSvbic.h>
111 #include <N_DEV_ADMSbsimcmg.h>
112 
113 #include <N_DEV_TransLine.h>
114 
115 #ifdef Xyce_EXTDEV
116 #include <N_DEV_ExternDevice.h>
117 #endif
118 
119 #ifdef Xyce_NONFREE_MODELS
120 #include <N_DEV_RegisterNonFreeDevices.h>
121 #endif
122 
123 #ifdef Xyce_RAD_MODELS
124 #include <N_DEV_RegisterSandiaDevices.h>
125 #endif
126 
127 namespace Xyce {
128 namespace Device {
129 
130 void registerDL(const char *so_path, const char *function_key = 0);
131 
132 void
134 {
192 
193 
194 #ifdef Xyce_EXTDEV
196 #endif
197 
198 #ifdef Xyce_RAD_MODELS
199  registerSandiaDevices();
200 #endif
201 
202 #ifdef Xyce_NONFREE_MODELS
203  registerNonFreeDevices();
204 #endif
205 }
206 
207 void
208 registerPlugin(const char *name)
209 {
210  registerDL(name);
211 }
212 
213 typedef void (*dl_register_t)();
214 
215 void registerDL(const char *so_path, const char *function_key) {
216 #ifdef HAVE_DLFCN_H
217  void *dl = dlopen(so_path, RTLD_NOW);
218  if (!dl) {
219  const char *error = dlerror();
220  Report::UserError0() << "Failed to load plugin " << error;
221  }
222  else {
223  if (function_key) {
224  std::string s = std::strlen(function_key) ? function_key : "dl_register";
225 
226  dl_register_t f = (dl_register_t) dlsym(dl, s.c_str());
227  if (!f) {
228  f = (dl_register_t) dlsym(dl, s.c_str());
229  }
230 
231  if (f) {
232  (*f)();
233  }
234  else {
235  if (std::strlen(function_key)) {
236  Report::UserError0() << "Executing dynamic library " << so_path << " function " << s << "()";
237  }
238  }
239  }
240  }
241 #endif // HAVE_DLFCN_H
242 }
243 
244 } // namespace Device
245 } // namespace Xyce