1 /*
2  *
3  * (C) 2003-2020 Anope Team
4  * Contact us at team@anope.org
5  *
6  * Please read COPYING and README for further details.
7  */
8 
9 #include "services.h"
10 #include "anope.h"
11 #include "service.h"
12 
13 std::map<Anope::string, std::map<Anope::string, Service *> > Service::Services;
14 std::map<Anope::string, std::map<Anope::string, Anope::string> > Service::Aliases;
15 
Base()16 Base::Base() : references(NULL)
17 {
18 }
19 
~Base()20 Base::~Base()
21 {
22 	if (this->references != NULL)
23 	{
24 		for (std::set<ReferenceBase *>::iterator it = this->references->begin(), it_end = this->references->end(); it != it_end; ++it)
25 			(*it)->Invalidate();
26 		delete this->references;
27 	}
28 }
29 
AddReference(ReferenceBase * r)30 void Base::AddReference(ReferenceBase *r)
31 {
32 	if (this->references == NULL)
33 		this->references = new std::set<ReferenceBase *>();
34 	this->references->insert(r);
35 }
36 
DelReference(ReferenceBase * r)37 void Base::DelReference(ReferenceBase *r)
38 {
39 	if (this->references != NULL)
40 	{
41 		this->references->erase(r);
42 		if (this->references->empty())
43 		{
44 			delete this->references;
45 			this->references = NULL;
46 		}
47 	}
48 }
49