Ice 3.7 C++11 API Reference
Loading...
Searching...
No Matches
DefaultValueFactory.h
Go to the documentation of this file.
1//
2// Copyright (c) ZeroC, Inc. All rights reserved.
3//
4
5#ifndef ICE_DEFAULT_VALUE_FACTORY_H
6#define ICE_DEFAULT_VALUE_FACTORY_H
7
8#include <Ice/Config.h>
9#include <Ice/ValueFactory.h>
10
11namespace IceInternal
12{
13
14#ifdef ICE_CPP11_MAPPING
15
16template<class V>
17::std::shared_ptr<::Ice::Value>
18#ifdef NDEBUG
19defaultValueFactory(const std::string&)
20#else
21defaultValueFactory(const std::string& typeId)
22#endif
23{
24 assert(typeId == V::ice_staticId());
25 return std::make_shared<V>();
26}
27
28#else
29
30template<class V>
31class DefaultValueFactory : public Ice::ValueFactory
32{
33public:
34
35 DefaultValueFactory(const ::std::string& typeId) :
36 _typeId(typeId)
37 {
38 }
39
40#ifndef NDEBUG
41 virtual ::Ice::ObjectPtr create(const ::std::string& typeId)
42#else
43 virtual ::Ice::ObjectPtr create(const ::std::string&)
44#endif
45 {
46 assert(typeId == _typeId);
47 return new V;
48 }
49
50private:
51 const ::std::string _typeId;
52};
53
54#endif
55
56}
57#endif
::std::function<::std::shared_ptr< Value >(const ::std::string &type)> ValueFactory
Create a new value for a given value type.
Definition ValueFactory.h:77