| 61 |
|
|
| 62 |
|
myConfiguration = new SimState(); |
| 63 |
|
|
| 64 |
+ |
properties = new GenericData(); |
| 65 |
+ |
|
| 66 |
|
wrapMeSimInfo( this ); |
| 67 |
|
} |
| 68 |
|
|
| 70 |
|
SimInfo::~SimInfo(){ |
| 71 |
|
|
| 72 |
|
delete myConfiguration; |
| 73 |
< |
|
| 72 |
< |
map<string, GenericData*>::iterator i; |
| 73 |
< |
|
| 74 |
< |
for(i = properties.begin(); i != properties.end(); i++) |
| 75 |
< |
delete (*i).second; |
| 76 |
< |
|
| 73 |
> |
delete properties; |
| 74 |
|
} |
| 75 |
|
|
| 76 |
|
void SimInfo::setBox(double newBox[3]) { |
| 639 |
|
} |
| 640 |
|
|
| 641 |
|
} |
| 645 |
– |
|
| 646 |
– |
void SimInfo::addProperty(GenericData* prop){ |
| 642 |
|
|
| 643 |
< |
map<string, GenericData*>::iterator result; |
| 649 |
< |
result = properties.find(prop->getID()); |
| 650 |
< |
|
| 651 |
< |
//we can't simply use properties[prop->getID()] = prop, |
| 652 |
< |
//it will cause memory leak if we already contain a propery which has the same name of prop |
| 653 |
< |
|
| 654 |
< |
if(result != properties.end()){ |
| 655 |
< |
|
| 656 |
< |
delete (*result).second; |
| 657 |
< |
(*result).second = prop; |
| 658 |
< |
|
| 659 |
< |
} |
| 660 |
< |
else{ |
| 643 |
> |
GenericData* SimInfo::getProperty(char* propName){ |
| 644 |
|
|
| 645 |
< |
properties[prop->getID()] = prop; |
| 663 |
< |
|
| 664 |
< |
} |
| 665 |
< |
|
| 645 |
> |
return properties->find( propName ); |
| 646 |
|
} |
| 647 |
|
|
| 668 |
– |
GenericData* SimInfo::getProperty(const string& propName){ |
| 669 |
– |
|
| 670 |
– |
map<string, GenericData*>::iterator result; |
| 671 |
– |
|
| 672 |
– |
//string lowerCaseName = (); |
| 673 |
– |
|
| 674 |
– |
result = properties.find(propName); |
| 675 |
– |
|
| 676 |
– |
if(result != properties.end()) |
| 677 |
– |
return (*result).second; |
| 678 |
– |
else |
| 679 |
– |
return NULL; |
| 680 |
– |
} |
| 681 |
– |
|
| 682 |
– |
vector<GenericData*> SimInfo::getProperties(){ |
| 683 |
– |
|
| 684 |
– |
vector<GenericData*> result; |
| 685 |
– |
map<string, GenericData*>::iterator i; |
| 686 |
– |
|
| 687 |
– |
for(i = properties.begin(); i != properties.end(); i++) |
| 688 |
– |
result.push_back((*i).second); |
| 689 |
– |
|
| 690 |
– |
return result; |
| 691 |
– |
} |
| 692 |
– |
|
| 648 |
|
double SimInfo::matTrace3(double m[3][3]){ |
| 649 |
|
double trace; |
| 650 |
|
trace = m[0][0] + m[1][1] + m[2][2]; |