56 std::map< std::string, creator_t *, std::less<std::string> >
factorycreate;
58 std::map< std::string, defs_t *, std::less<std::string> >
factorydef;
62 std::list<HINSTANCE>::iterator
itr;
65 std::list<void *>::iterator
itr;
95 void module::registerModule (analysis_definer_t define,
96 analysis_creator_t create) {
97 module * m =
new module ();
98 m->definition = define ();
99 m->anacreate = create;
100 modules.put ((
char *) define()->
type, m);
104 void module::registerModule (circuit_definer_t define,
105 circuit_creator_t create) {
106 module * m =
new module ();
107 m->definition = define ();
108 m->circreate = create;
109 registerModule (define()->
type, m);
113 void module::registerModule (misc_definer_t define) {
114 module * m =
new module ();
115 m->definition = define ();
116 registerModule (define()->
type, m);
121 void module::registerModule (
struct define_t * define) {
122 module * m =
new module ();
123 m->definition = define;
124 registerModule (define->
type, m);
128 void module::registerModule (
const char *
type, module * m) {
129 if (modules.get ((
char *) type) != NULL) {
133 modules.put ((
char *) type, m);
139 struct define_t * module::getModule (
char * type) {
140 module * m = modules.get (type);
148 #define REGISTER_CIRCUIT(val) \
149 registerModule (&val::definition, &val::create)
150 #define REGISTER_ANALYSIS(val) \
151 registerModule (&val::definition, &val::create)
152 #define REGISTER_MISC(val) \
153 registerModule (&val::definition)
156 void module::registerModules (
void) {
159 registerModule (&miscdef1);
160 registerModule (&miscdef2);
323 void module::unregisterModules (
void) {
333 static const char * def_prefix =
335 " * qucsdefs.h - netlist definitions for the Qucs netlists\n"
337 " * This is free software; you can redistribute it and/or modify\n"
338 " * it under the terms of the GNU General Public License as published by\n"
339 " * the Free Software Foundation; either version 2, or (at your option)\n"
340 " * any later version.\n"
344 "#ifndef __QUCSDEFS_H__\n"
345 "#define __QUCSDEFS_H__\n";
348 static const char * def_suffix =
350 "#endif /* __QUCSDEFS_H__ */\n";
353 static const char * def_start =
355 "// List of available components.\n"
356 "struct define_t qucs_definition_available[] =\n";
359 static const char * def_stop =
361 "static struct define_t def_End = {\n"
362 " ((char *) 0), -1, 1, 0, 0, req_Def, opt_Def };\n";
365 static char * printstr (
const char * str) {
366 static char txt[256];
368 sprintf (txt,
"%s%s%s",
369 (str && !nostr) ?
"\"" :
"",
370 str ? nostr ?
"((char *) -1)" : str :
"((char *) 0)",
371 (str && !nostr) ?
"\"" :
"");
376 static void printprop (
const char * type,
const char *
prefix,
381 fprintf (stdout,
"static struct property_t %s_%s[] = {\n", prefix, type);
384 fprintf (stdout,
" { %s, %d, ", printstr (key), prop->
type);
385 fprintf (stdout,
"{ %g, %s }, ", prop->
defaultval.
d,
387 fprintf (stdout,
"{ '%c', %g, %g, '%c',\n",
389 fprintf (stdout,
" {");
393 fprintf (stdout,
" %s", printstr (txt));
394 if (txt) fprintf (stdout,
",");
398 fprintf (stdout,
" } } }");
399 if (key) fprintf (stdout,
",");
400 fprintf (stdout,
"\n");
404 fprintf (stdout,
"};\n");
409 void module::print (
void) {
410 fprintf (stdout,
"%s", def_prefix);
414 struct define_t * def = m->definition;
415 fprintf (stdout,
"\n");
417 fprintf (stdout,
"\n");
419 fprintf (stdout,
"\n");
420 fprintf (stdout,
"static struct define_t def_%s = {\n", def->
type);
421 fprintf (stdout,
" %s, %d, %d, %d, %d, req_%s, opt_%s };\n",
425 fprintf (stdout,
"%s", def_stop);
426 fprintf (stdout,
"%s", def_start);
427 fprintf (stdout,
"{\n");
430 struct define_t * def = m->definition;
431 fprintf (stdout,
" def_%s,\n", def->
type);
433 fprintf (stdout,
" def_End\n");
434 fprintf (stdout,
"};\n");
435 fprintf (stdout,
"%s", def_suffix);
441 void module::registerDynamicModules (
char *proj, std::list<std::string> modlist)
458 fprintf(stdout,
"project location: %s\n", proj);
459 fprintf(stdout,
"modules to load: %lu\n", modlist.size());
461 std::list<std::string>::iterator it;
462 for (it=modlist.begin(); it!=modlist.end(); ++it) {
464 std::string absPathLib = proj;
467 absPathLib = absPathLib +
"/" + *it +
".dylib";
470 absPathLib = absPathLib +
"/" + *it +
".so";
473 absPathLib = absPathLib +
"\\" + *it +
".dll";
477 fprintf( stdout,
"try loading %s\n", absPathLib.c_str() );
481 HINSTANCE dlib = ::LoadLibrary(TEXT(absPathLib.c_str()));
483 std::cerr <<
"Unable to load DLL!\n";
486 #else //Linux and OSX
489 void* dlib = dlopen(absPathLib.c_str(), RTLD_NOW|RTLD_LOCAL);
491 std::cerr << dlerror() << std::endl;
502 std::cout <<
"factorycreate.size() is " <<
factorycreate.size() <<
'\n';
503 std::cout <<
"factorycreate has registered:";
506 std::map<std::string, creator_t *, std::less<std::string> >::iterator fitr;
508 std::cout <<
' ' << fitr->first;
527 m->circreate = mycreate;
528 m->definition = mydefine;
530 if (modules.get ((
char *) mydefine->
type) != NULL) {
534 modules.put ((
char *) mydefine->
type, m);
553 void module::closeDynamicLibs()
type_t * currentVal(void)
std::map< std::string, defs_t *, std::less< std::string > > factorydef
#define REGISTER_MISC(val)
static struct property_t props1[]
#define REGISTER_CIRCUIT(val)
struct property_t * required
#define REGISTER_ANALYSIS(val)
struct property_t::@6 defaultval
std::list< void * > dl_list
struct property_t::@7 range
std::list< void * >::iterator itr
static struct property_t props2[]
global analysis header file
External interface class for transient simulation.
struct property_t * optional
struct define_t * definition
void logprint(int level, const char *format,...)
#define PROP_NO_SUBSTRATE
std::map< std::string, creator_t *, std::less< std::string > > factorycreate