| 79 | extern FE_Datastore *theDatabase; |
| 80 | |
| 81 | int |
| 82 | TclAddDatabase(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv, |
| 83 | Domain &theDomain, |
| 84 | FEM_ObjectBroker &theBroker) |
| 85 | { |
| 86 | if (createdDatabaseCommands == false) { |
| 87 | |
| 88 | // create the commands to commit and reset |
| 89 | Tcl_CreateCommand(interp, "save", save, |
| 90 | (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); |
| 91 | Tcl_CreateCommand(interp, "restore", restore, |
| 92 | (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); |
| 93 | |
| 94 | createdDatabaseCommands = true; |
| 95 | } |
| 96 | |
| 97 | // make sure at least one other argument to contain integrator |
| 98 | if (argc < 2) { |
| 99 | opserr << "WARNING need to specify a Database type; valid type File, MySQL, BerkeleyDB \n"; |
| 100 | return TCL_ERROR; |
| 101 | } |
| 102 | |
| 103 | // |
| 104 | // check argv[1] for type of Database, parse in rest of arguments |
| 105 | // needed for the type of Database, create the object and add to Domain |
| 106 | // |
| 107 | |
| 108 | // a File Database |
| 109 | if (strcmp(argv[1],"File") == 0) { |
| 110 | if (argc < 3) { |
| 111 | opserr << "WARNING database File fileName? "; |
| 112 | return TCL_ERROR; |
| 113 | } |
| 114 | |
| 115 | // delete the old database |
| 116 | if (theDatabase != 0) |
| 117 | delete theDatabase; |
| 118 | |
| 119 | theDatabase = new FileDatastore(argv[2], theDomain, theBroker); |
| 120 | // check we instantiated a database .. if not ran out of memory |
| 121 | if (theDatabase == 0) { |
| 122 | opserr << "WARNING ran out of memory - database File " << argv[2] << endln; |
| 123 | return TCL_ERROR; |
| 124 | } |
| 125 | |
| 126 | return TCL_OK; |
| 127 | } else { |
| 128 | |
| 129 | // |
| 130 | // maybe a database package |
| 131 | // |
| 132 | |
| 133 | // try existing loaded packages |
| 134 | |
| 135 | DatabasePackageCommand *dataCommands = theDatabasePackageCommands; |
| 136 | bool found = false; |
| 137 | while (dataCommands != NULL && found == false) { |
| 138 | if (strcmp(argv[1], dataCommands->funcName) == 0) { |
no test coverage detected