-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbase.hpp
55 lines (41 loc) · 1.46 KB
/
base.hpp
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#ifndef ATTR_HANDLER_BASE_HPP__
#define ATTR_HANDLER_BASE_HPP__
/*
* Authors: Cheinan Marks
*
* File Description:
* Base class for the backend handlers. Backend handlers must derive from
* this class and implement either Set, Get or both. If the derived handler
* does not implement a method and it is called, a link error will result.
*/
#include <string>
#include <vector>
#include <boost/any.hpp>
#include "loki_type_info.hpp"
#include "any_property_exception.hpp"
class CAnyHandlerBase
{
public:
CAnyHandlerBase() {}
virtual ~CAnyHandlerBase() {}
virtual boost::any Get( const std::string & /*key*/ ) const
{
throw CAnyPropertyException(CAnyPropertyException::eNoGet);
return boost::any();
}
virtual void Set( const std::string & key, const boost::any & /*value*/ )
{
throw CAnyPropertyException(CAnyPropertyException::eNoSet);
}
/// Override with a method returning the name of the handler for error
/// reporting.
virtual std::string Name() const = 0;
/// The overridden method must create and return a vector of all the types
/// that the handler supports. The helper function, CreateTypeVector, in
/// TypelistHelper.hpp is very handy here.
virtual std::vector<Loki::TypeInfo> GetHandledTypes() const = 0;
private:
CAnyHandlerBase(const CAnyHandlerBase&);
CAnyHandlerBase& operator=(const CAnyHandlerBase&);
};
#endif // ATTR_HANDLER_BASE_HPP__