Atoms Crowd  4.1.0
CacheLayoutGenerator.h
1 #pragma once
2 // ===========================================================================
3 // Copyright (c) 2015 Toolchefs Ltd. All rights reserved.
4 //
5 // Use of this software is subject to the terms of the Toolchefs license
6 // agreement provided at the time of installation or download, or which
7 // otherwise accompanies this software in either electronic or hard copy form.
8 // ===========================================================================
9 
10 #include <Atoms/LayoutGenerators/LayoutGenerator.h>
11 #include <set>
12 
13 namespace Atoms
14 {
15  class ATOMS_EXPORT CacheLayoutGenerator : public LayoutGenerator
16  {
17  public:
18 
20 
21  virtual ~CacheLayoutGenerator();
22 
23  virtual std::vector<AgentInitData> generate(double time)
24 #ifdef __APPLE__
25  override
26 #endif
27  ;
28 
29  inline bool allowMultiLayoutGenerator() override { return false; }
30 
31  inline AtomsCore::Matrix matrix() const { return m_matrix; }
32 
33  inline void setMatrix(const AtomsCore::Matrix& mtx) { m_matrix = mtx; }
34 
35  inline void setCache(const std::string& cachePath, const std::string& cacheName)
36  {
37  m_cachePath = cachePath;
38  m_cacheName = cacheName;
39  }
40 
41  inline void setNewAgents(const std::vector<int>& newAgents) { m_newAgents = newAgents; }
42 
43  void setAgentsFilter(const std::vector<int>& newAgents);
44 
45  inline void setCacheFrame(double value) { m_cacheFrame = value; };
46 
47  inline void setStartFrame(double value) { m_startFrame = value; };
48 
49  inline void setAgentsTimes(std::unordered_map<int, double>* value) { m_agentsTime = value; };
50 
51  inline size_t getAgentCacheId(size_t id) { return m_agentIds[id]; };
52 
53  inline void addAgentCacheId(size_t id, size_t value) { m_agentIds[id] = value; };
54 
55  void setExtraAgents(const std::unordered_map<size_t, size_t>& extraAgents);
56 
57  void setTimeOffsetInPlace(const bool value, const std::unordered_map<int, bool> &overrides) { m_timeOffsetInPlace = value; m_timeOffsetInPlaces = overrides; }
58 
59  inline const char* typeName() override { return "cacheReader"; };
60 
61  private:
62 
63  AtomsCore::Matrix m_matrix;
64 
65  std::vector<int> m_newAgents;
66 
67  std::unordered_map<int, bool> m_agentsFilter;
68 
69  bool m_timeOffsetInPlace;
70 
71  std::unordered_map<int, bool> m_timeOffsetInPlaces;
72 
73  std::unordered_map<int, double>* m_agentsTime;
74 
75  std::unordered_map<size_t, size_t> m_agentIds;
76 
77  std::unordered_map<size_t, size_t> m_extraAgents;
78 
79  std::string m_cachePath;
80 
81  std::string m_cacheName;
82 
83  double m_cacheFrame;
84 
85  double m_startFrame;
86 
87  std::set<int> m_agentsCreated;
88  };
89 }
90 
Atoms::CacheLayoutGenerator::generate
virtual std::vector< AgentInitData > generate(double time)
Generate a vector of agent init data.
AtomsCore::Matrix
AtomsMath::Matrix Matrix
Matrix class.
Definition: AtomsMath.h:63
Atoms
Atoms namespace.
Definition: Agent.h:28
Atoms::CacheLayoutGenerator::typeName
const char * typeName() override
Get the type name for this generator.
Definition: CacheLayoutGenerator.h:59
Atoms::LayoutGenerator
Layout generator.
Definition: LayoutGenerator.h:29
Atoms::CacheLayoutGenerator
Definition: CacheLayoutGenerator.h:16
Atoms::CacheLayoutGenerator::allowMultiLayoutGenerator
bool allowMultiLayoutGenerator() override
Returns whether this layout generator can work in conjunction with other layout generators.
Definition: CacheLayoutGenerator.h:29