Atoms Crowd  7.0.0
Locomotions.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/Globals.h>
11 #include <Atoms/Locomotion.h>
12 #include <map>
13 #include <vector>
14 #include <functional>
15 #include <mutex>
16 
17 namespace Atoms
18 {
20 
22  class ATOMS_EXPORT Locomotions
23  {
24  public:
25 
27  static Locomotions& instance();
28 
30 
34  LocomotionCPtr locomotion(const std::string& name) const;
35 
37 
41  LocomotionPtr locomotion(const std::string& name);
42 
44 
48  void addLocomotion(const std::string& name, const Atoms::Locomotion& locomotion, bool replace = true);
49 
51 
55  void addLocomotion(const std::string& name, LocomotionPtr& locomotionPtr, bool replace = true);
56 
58 
61  void removeLocomotion(const std::string& name);
62 
64 
67  std::vector<std::string> locomotionNames();
68 
70 
74  bool locomotionExists(const std::string& name);
75 
77  unsigned int numLocomotions();
78 
80  void clear();
81 
82  void registerLoaderCallback(std::function<Locomotion(const char*)>& callback);
83 
84  private:
85 
87  Locomotions();
88 
90  Locomotions(const Locomotions&);
91 
93  ~Locomotions();
94 
96  Locomotions& operator=(const Locomotions&);
97 
98  typedef std::map<std::string, LocomotionPtr> LocomotionsMap;
99 
101 
104  LocomotionsMap m_locomotionsMap;
105 
106  std::function<Locomotion(const char*)> m_loaderCallback;
107 
108  mutable std::mutex m_mutex;
109  };
110 }
Animation clip.
Definition: Locomotion.h:34
Locomotions manager.
Definition: Locomotions.h:23
static Locomotions & instance()
Singleton access.
std::vector< std::string > locomotionNames()
Get all locomotion names.
LocomotionPtr locomotion(const std::string &name)
Return a locomotion.
LocomotionCPtr locomotion(const std::string &name) const
Return a locomotion.
void addLocomotion(const std::string &name, const Atoms::Locomotion &locomotion, bool replace=true)
Add a locomotion to the map.
void clear()
Remove all locomotions.
void addLocomotion(const std::string &name, LocomotionPtr &locomotionPtr, bool replace=true)
Add a locomotion to the map.
unsigned int numLocomotions()
Get number of locomotions.
void removeLocomotion(const std::string &name)
Remove a locomotion from the map.
bool locomotionExists(const std::string &name)
Check if a locomotion exists.
Atoms namespace.
Definition: Agent.h:29
AtomsPtr< Locomotion > LocomotionPtr
locomotion pointer
Definition: Locomotion.h:84
AtomsPtr< const Locomotion > LocomotionCPtr
locomotion const pointer
Definition: Locomotion.h:86