1 //******************************************************************
3 // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 #ifndef OC_WRAPPER_FACTORY_H_
22 #define OC_WRAPPER_FACTORY_H_
26 #include "IClientWrapper.h"
27 #include "IServerWrapper.h"
28 #include <OutOfProcClientWrapper.h>
29 #include <InProcClientWrapper.h>
30 #include <OutOfProcServerWrapper.h>
31 #include <InProcServerWrapper.h>
32 #include "StringConstants.h"
36 // Interface to permit easier mocking/unit testing later
40 typedef std::shared_ptr<IWrapperFactory> Ptr;
42 virtual IClientWrapper::Ptr CreateClientWrapper(
43 std::weak_ptr<std::recursive_mutex> csdkLock, PlatformConfig cfg) =0;
44 virtual IServerWrapper::Ptr CreateServerWrapper(
45 std::weak_ptr<std::recursive_mutex> csdkLock, PlatformConfig cfg) =0;
46 virtual ~IWrapperFactory(){}
49 // Class to create the client/server object!
50 class WrapperFactory : public IWrapperFactory
55 virtual IClientWrapper::Ptr CreateClientWrapper(
56 std::weak_ptr<std::recursive_mutex> csdkLock, PlatformConfig cfg)
58 switch(cfg.serviceType)
60 case ServiceType::InProc:
61 return std::make_shared<InProcClientWrapper>(csdkLock, cfg);
63 case ServiceType::OutOfProc:
64 return std::make_shared<OutOfProcClientWrapper>(csdkLock, cfg);
70 virtual IServerWrapper::Ptr CreateServerWrapper(
71 std::weak_ptr<std::recursive_mutex> csdkLock, PlatformConfig cfg)
73 switch(cfg.serviceType)
75 case ServiceType::InProc:
76 return std::make_shared<InProcServerWrapper>(csdkLock, cfg);
78 case ServiceType::OutOfProc:
79 throw OC::OCException(OC::Exception::SVCTYPE_OUTOFPROC, OC_STACK_NOTIMPL);
85 virtual ~WrapperFactory(){}