Ice 3.7 C++11 API Reference
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 
11 namespace IceInternal
12 {
13 
14 #ifdef ICE_CPP11_MAPPING
15 
16 template<class V>
17 ::std::shared_ptr<::Ice::Value>
18 #ifdef NDEBUG
19 defaultValueFactory(const std::string&)
20 #else
21 defaultValueFactory(const std::string& typeId)
22 #endif
23 {
24  assert(typeId == V::ice_staticId());
25  return std::make_shared<V>();
26 }
27 
28 #else
29 
30 template<class V>
31 class DefaultValueFactory : public Ice::ValueFactory
32 {
33 public:
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 
50 private:
51  const ::std::string _typeId;
52 };
53 
54 #endif
55 
56 }
57 #endif
ValueFactory.h
Ice::ValueFactory
::std::function<::std::shared_ptr< Value >(const ::std::string &type)> ValueFactory
Create a new value for a given value type.
Definition: ValueFactory.h:77
Config.h