Flatland
entity.h
1 /*
2  * ______ __ __ __
3  * /\ _ \ __ /\ \/\ \ /\ \__
4  * \ \ \L\ \ __ __ /\_\ \_\ \ \ \____ ___\ \ ,_\ ____
5  * \ \ __ \/\ \/\ \\/\ \ /'_` \ \ '__`\ / __`\ \ \/ /',__\
6  * \ \ \/\ \ \ \_/ |\ \ \/\ \L\ \ \ \L\ \/\ \L\ \ \ \_/\__, `\
7  * \ \_\ \_\ \___/ \ \_\ \___,_\ \_,__/\ \____/\ \__\/\____/
8  * \/_/\/_/\/__/ \/_/\/__,_ /\/___/ \/___/ \/__/\/___/
9  * @copyright Copyright 2017 Avidbots Corp.
10  * @name entity.h
11  * @brief Defines flatland Entity
12  * @author Chunshang Li
13  *
14  * Software License Agreement (BSD License)
15  *
16  * Copyright (c) 2017, Avidbots Corp.
17  * All rights reserved.
18  *
19  * Redistribution and use in source and binary forms, with or without
20  * modification, are permitted provided that the following conditions
21  * are met:
22  *
23  * * Redistributions of source code must retain the above copyright
24  * notice, this list of conditions and the following disclaimer.
25  * * Redistributions in binary form must reproduce the above
26  * copyright notice, this list of conditions and the following
27  * disclaimer in the documentation and/or other materials provided
28  * with the distribution.
29  * * Neither the name of the Avidbots Corp. nor the names of its
30  * contributors may be used to endorse or promote products derived
31  * from this software without specific prior written permission.
32  *
33  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
34  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
35  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
36  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
37  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
38  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
39  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
40  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
41  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
42  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
43  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
44  * POSSIBILITY OF SUCH DAMAGE.
45  */
46 
47 #ifndef FLATLAND_SERVER_ENTITY_H
48 #define FLATLAND_SERVER_ENTITY_H
49 
50 #include <Box2D/Box2D.h>
51 #include <flatland_server/yaml_reader.h>
52 #include <yaml-cpp/yaml.h>
53 
54 namespace flatland_server {
55 
61 class Entity {
62  public:
64  enum EntityType { LAYER, MODEL };
65 
66  b2World *physics_world_;
67  std::string name_;
68 
74  Entity(b2World *physics_world, const std::string &name);
75  virtual ~Entity() = default;
76 
80  const std::string &GetName() const;
81 
87  b2World *GetPhysicsWorld();
88 
91  Entity(const Entity &) = delete;
92  Entity &operator=(const Entity &) = delete;
93 
98  virtual EntityType Type() const = 0;
99 
103  virtual void DebugVisualize() const = 0;
104 
108  virtual void DebugOutput() const = 0;
109 };
110 }; // namespace flatland_server
111 #endif // FLATLAND_SERVER_ENTITY_H
EntityType
Defines the type of entity.
Definition: entity.h:64
b2World * GetPhysicsWorld()
Get Box2D physics world.
Definition: entity.cpp:57
Definition: entity.h:61
virtual void DebugVisualize() const =0
Visualize the entity.
Entity(b2World *physics_world, const std::string &name)
Constructor for the entity.
Definition: entity.cpp:52
Definition: body.h:55
b2World * physics_world_
Box2D physics world.
Definition: entity.h:66
const std::string & GetName() const
Definition: entity.cpp:55
virtual EntityType Type() const =0
Get the type of entity, subclasses must override.
virtual void DebugOutput() const =0
Print debug message for the entity.
std::string name_
name of the entity
Definition: entity.h:67