Thank you to anyone who has already donated - your generous donations helped make three months of treatment possible.

My brother Nate continues to fight stage IV Hodgkin's lymphoma. He's just 31, with a wife and baby girl. They have no active income (since he's been unable to return to work), no insurance, and cannot afford the treatment he needs. Nate and his family need your help. Please consider a donation, every dollar helps. Thanks.


Entity.h

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#ifndef ENTITY_H_
#define ENTITY_H_

#include <vector>

class Component;

class Entity {
private:
	std::vector<Component*> componentPtrs;

public:
	~Entity();
	void addComponent(Component* mComponentPtr);
	void delComponent(Component* mComponentPtr);
	void update();
};

#endif /* ENTITY_H_ */

Entity.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
#include <vector>
#include <list>
#include <string>
#include <sstream>
#include <algorithm>

#include "Entity.h"
#include "Component.h"

using namespace std;

void Entity::update() {
	componentPtrs[0]->update();
}

Component.h

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#ifndef COMPONENT_H_
#define COMPONENT_H_

class Entity;

class Component {
private:
	Entity* parentPtr;

public:
	virtual void init();
	virtual void update() = 0;
	virtual ~Component();
	void setParent(Entity* mParentPtr);
};

#endif /* COMPONENT_H_ */

Component.cpp

1
2
3
4
#include "Component.h"

void Component::setParent(Entity* mParentPtr) { parentPtr = mParentPtr; }
void Component::update() { }