プログラムに、3D空間に配置されるシェイプオブジェクトがあります。形状のプロパティは次のようになります。
struct Shape{
Vector3 position,
TYPE shapeType,
std::string resourcePath
};
XmlReader
map<Shape, Vector3> locations;
//Add pairs to map by reading from xml file, for eg:
//Initializing struct
Shape _shape = {
node->getPosition(), //position of the card in xml
node->getType(),
node->getPath()
}
//Add to map
上記map
はXmlReaderクラスのパブリックフィールドであり、メインプログラムでは、マップを反復処理して図形を空間に配置します。
この場合、struct
マップから位置と形状を取得するために、メインプログラムでもを初期化する必要があります。
例:
マップイテレータでは、
for(std::map<Shape, Vector3>::iterator itr=locations.begin();itr!location.end();++itr)
Shape _Receivedshape = itr->first;
std::string resulttring = _Receivedshape.resourcePath;
メインプログラムでも構造を初期化しているので、上記は正しい実装です。そうでない場合、ここで使用するためのより良い実装は何でしょうか?