Esempio n. 1
0
bool OPS_removeMesh(int tag)
{
    TaggedObject* obj = theMeshObjects.removeComponent(tag);
    if (obj != 0) {
        delete obj;
        return true;
    }
    return false;
}
Esempio n. 2
0
bool OPS_removeUniaxialMaterial(int tag)
{
    TaggedObject* obj = theUniaxialMaterialObjects.removeComponent(tag);
    if (obj != 0) {
	delete obj;
	return true;
    }
    return false;
}
Esempio n. 3
0
int main(int argc, char **argv)
{
    int startID = 1;
    int i;

    MapOfTaggedObjects *theHolder = new MapOfTaggedObjects();
    opserr << "adding 5 components starting with id 1 to an object of initial size 5\n";

    for (i=0; i<5; i++) {
	Node *theNode = new Node(i+startID,1,i+startID);
	theHolder->addComponent(theNode);
    }
    
    opserr << "the contents\n";    
    theHolder->Print(opserr);

    TaggedObject *theNode;
    
    opserr << "removing node with id 4\n";
    theNode = theHolder->removeComponent(4); 
    if (theNode != 0) opserr << *theNode; else opserr << "Not There\n";        

    opserr << "the contents\n";    
    theHolder->Print(opserr);

    opserr << "adding 3 more components 10,11,12\n";        
    for (i=0; i<3; i++) {
	Node *theNode = new Node(i+10,1,i+10);
	theHolder->addComponent(theNode);
    }

    opserr << "the contents\n";    
    theHolder->Print(opserr);
    
    // destroying the holder
    opserr << "invoking the object destructor\n";        
    delete theHolder;
    
    opserr << "end of test1\n";
    double a; cin >> a;
    
    startID = 0;
    theHolder = new MapOfTaggedObjects();
    opserr << "adding 5 components starting with id 0 to an object of initial size 5\n";

    for (i=0; i<5; i++) {
	Node *theNode = new Node(i+startID,1,i+startID);
	theHolder->addComponent(theNode);
    }
    
    opserr << "the contents\n";    
    theHolder->Print(opserr);

    opserr << "removing node with id 4\n";
    theNode = theHolder->removeComponent(4); 
    if (theNode != 0) opserr << *theNode; else opserr << "Not There\n";        

    opserr << "the contents\n";    
    theHolder->Print(opserr);    
    
    opserr << "adding 3 more components 10,11,12\n";        
    for (i=0; i<3; i++) {
	Node *theNode = new Node(i+startID,1,i+10);
	theHolder->addComponent(theNode);
    }

    opserr << "the contents using print\n";    
    theHolder->Print(opserr);    

    opserr << "now check that the iterator works - should see contents\n";
    TaggedObject *theItem;
    TaggedObjectIter &theItems = theHolder->getComponents();
    while ((theItem = theItems()) != 0)
	opserr << *theItem;
    
    theHolder->clearAll();
    opserr << "the contetnts after clearAll\n";            
    theHolder->Print(opserr);
}