| 58 | |
| 59 | |
| 60 | int |
| 61 | removeObject(ClientData clientData, Tcl_Interp *interp, int argc, |
| 62 | Tcl_Obj *const *objv) |
| 63 | { |
| 64 | assert(clientData != nullptr); |
| 65 | Domain * the_domain = (Domain*)clientData; |
| 66 | |
| 67 | // make sure at least one other argument to contain type of object |
| 68 | if (argc < 2) { |
| 69 | opserr << "WARNING want - remove objectType?\n"; |
| 70 | return TCL_ERROR; |
| 71 | } |
| 72 | const char* remove_type = Tcl_GetString(objv[1]); |
| 73 | |
| 74 | int tag; |
| 75 | if ((strcmp(remove_type, "element") == 0) || |
| 76 | (strcmp(remove_type, "ele") == 0)) { |
| 77 | if (argc < 3) { |
| 78 | opserr << "WARNING want - remove element eleTag?\n"; |
| 79 | return TCL_ERROR; |
| 80 | } |
| 81 | |
| 82 | if (Tcl_GetIntFromObj(interp, objv[2], &tag) != TCL_OK) { |
| 83 | opserr << "WARNING remove element tag? failed to read tag: " |
| 84 | << Tcl_GetString(objv[2]) << "\n"; |
| 85 | return TCL_ERROR; |
| 86 | } |
| 87 | Element *theEle = the_domain->removeElement(tag); |
| 88 | if (theEle != nullptr) { |
| 89 | |
| 90 | // finally invoke the destructor on the element |
| 91 | delete theEle; |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | else if ((strcmp(remove_type, "loadPattern") == 0) || |
| 96 | (strcmp(remove_type, "pattern") == 0)) { |
| 97 | if (argc < 3) { |
| 98 | opserr << "WARNING want - remove loadPattern patternTag?\n"; |
| 99 | return TCL_ERROR; |
| 100 | } |
| 101 | if (Tcl_GetIntFromObj(interp, objv[2], &tag) != TCL_OK) { |
| 102 | opserr << "WARNING remove loadPattern tag? failed to read tag: " |
| 103 | << Tcl_GetString(objv[2]) << "\n"; |
| 104 | return TCL_ERROR; |
| 105 | } |
| 106 | LoadPattern *thePattern = the_domain->removeLoadPattern(tag); |
| 107 | if (thePattern != nullptr) { |
| 108 | thePattern->clearAll(); |
| 109 | delete thePattern; |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | else if (strcmp(remove_type, "parameter") == 0) { |
| 114 | if (argc < 3) { |
| 115 | opserr << "WARNING want - remove parameter paramTag?\n"; |
| 116 | return TCL_ERROR; |
| 117 | } |
nothing calls this directly
no test coverage detected