All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
CollisionMaterialTable.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "Collision.h"
6 #include "CollisionMaterial.h"
7 
8 #include <vector>
9 #include <string>
10 #include <algorithm>
11 
12 namespace Eegeo
13 {
14  namespace Collision
15  {
17  {
18  CollisionMaterialTable(const std::vector<CollisionMaterial>& collisionMaterials)
19  : m_collisionMaterials(collisionMaterials)
20  {}
21 
22  std::string IdAtIndex(int tableIndex) const { return m_collisionMaterials.at(tableIndex).MaterialId(); }
23 
24  bool Contains(const std::string materialId) const
25  {
26  return std::find_if(m_collisionMaterials.begin(), m_collisionMaterials.end(), MatchesId(materialId)) != m_collisionMaterials.end();
27  }
28 
29  int FindIndexOf(const std::string materialId) const
30  {
31  std::vector<CollisionMaterial>::const_iterator iter = std::find_if(m_collisionMaterials.begin(), m_collisionMaterials.end(), MatchesId(materialId));
32  if (iter == m_collisionMaterials.end())
33  return -1;
34  else
35  return static_cast<int>(std::distance(m_collisionMaterials.begin(), iter));
36  }
37 
38  const std::vector<CollisionMaterial>& GetCollisionMaterials() const { return m_collisionMaterials; }
39 
40  private:
41  std::vector<CollisionMaterial> m_collisionMaterials;
42  };
43  }
44 }