summaryrefslogtreecommitdiffstats
blob: db86eea9c7e6c77fbe0d58550917a316918d011e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <boost/bind.hpp>
#include <algorithm>

#include "Swiften/Serializer/PayloadSerializerCollection.h"
#include "Swiften/Serializer/PayloadSerializer.h"

namespace Swift {

PayloadSerializerCollection::PayloadSerializerCollection() {
}

void PayloadSerializerCollection::addSerializer(PayloadSerializer* serializer) {
	serializers_.push_back(serializer);
}

void PayloadSerializerCollection::removeSerializer(PayloadSerializer* serializer) {
	serializers_.erase(remove(serializers_.begin(), serializers_.end(), serializer), serializers_.end());
}

PayloadSerializer* PayloadSerializerCollection::getPayloadSerializer(boost::shared_ptr<Payload> payload) const {
	std::vector<PayloadSerializer*>::const_iterator i = std::find_if(
			serializers_.begin(), serializers_.end(), 
			boost::bind(&PayloadSerializer::canSerialize, _1, payload));
	return (i != serializers_.end() ? *i : NULL);
}

}