IoTivity C++ SDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RCSResponse.h
Go to the documentation of this file.
1 //******************************************************************
2 //
3 // Copyright 2015 Samsung Electronics All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
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
10 //
11 // http://www.apache.org/licenses/LICENSE-2.0
12 //
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.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20 
21 
27 #ifndef SERVERBUILDER_RCSRESPONSE_H
28 #define SERVERBUILDER_RCSRESPONSE_H
29 
30 #include <memory>
31 
32 namespace OIC
33 {
34  namespace Service
35  {
36  class RCSResourceAttributes;
37 
38  class RequestHandler;
39  class SetRequestHandler;
40 
48  {
49  public:
57 
68  static RCSGetResponse create(int errorCode);
69 
85  static RCSGetResponse create(const RCSResourceAttributes& attrs);
86 
98 
115  static RCSGetResponse create(const RCSResourceAttributes& attrs, int errorCode);
116 
128  static RCSGetResponse create(RCSResourceAttributes&& attrs, int errorCode);
129 
139  static RCSGetResponse separate();
140 
146  bool isSeparate() const;
147 
149  RequestHandler* getHandler() const;
151 
152  private:
153  RCSGetResponse();
154  RCSGetResponse(std::shared_ptr< RequestHandler >&&);
155 
156  private:
157  std::shared_ptr< RequestHandler > m_handler;
158  };
159 
169  {
170  public:
179  enum class AcceptanceMethod
180  {
184  DEFAULT,
185 
189  ACCEPT,
190 
194  IGNORE
195  };
196 
203  static RCSSetResponse defaultAction();
204 
212  static RCSSetResponse accept();
213 
223  static RCSSetResponse accept(int errorCode);
224 
231  static RCSSetResponse ignore();
232 
240  static RCSSetResponse ignore(int errorCode);
241 
253  static RCSSetResponse create(int errorCode);
254 
269  static RCSSetResponse create(const RCSResourceAttributes& attrs);
270 
281 
297  static RCSSetResponse create(const RCSResourceAttributes& attrs, int errorCode);
298 
309  static RCSSetResponse create(RCSResourceAttributes&& attrs, int errorCode);
310 
320  static RCSSetResponse separate();
321 
327  bool isSeparate() const;
328 
330  SetRequestHandler* getHandler() const;
332 
338 
350 
351  private:
352  RCSSetResponse();
353  RCSSetResponse(std::shared_ptr< SetRequestHandler >&&);
354  RCSSetResponse(std::shared_ptr< SetRequestHandler >&&, AcceptanceMethod);
355 
356  private:
357  AcceptanceMethod m_acceptanceMethod;
358  std::shared_ptr< SetRequestHandler > m_handler;
359  };
360  }
361 }
362 
363 #endif // SERVERBUILDER_RCSRESPONSE_H
AcceptanceMethod
Options for handling a set request.
Definition: RCSResponse.h:179
RCSSetResponse & setAcceptanceMethod(AcceptanceMethod method)
Sets the acceptance method for the RCSSetResponse.
bool isSeparate() const
Returns whether it is a separate response.
static RCSSetResponse defaultAction()
Creates a default RCSSetResponse that has AcceptanceMethod::DEFAULT.
This class provides factory methods to create the response for a received get request.
Definition: RCSResponse.h:47
Follow SetRequestHandlerPolicy of the RCSResourceObject.
AcceptanceMethod getAcceptanceMethod() const
Returns the acceptance method.
static RCSSetResponse accept()
Creates a default RCSSetResponse that has AcceptanceMethod::ACCEPT.
static RCSSetResponse ignore()
Creates a default RCSSetResponse that has AcceptanceMethod::IGNORE.
static RCSSetResponse create(int errorCode)
Creates a RCSSetResponse that has AcceptanceMethod::DEFAULT and error code passed.
Accept the request attributes even if there is an unknown key or mismatched type. ...
This represents the attributes for a resource.
Definition: RCSResourceAttributes.h:195
static RCSGetResponse defaultAction()
Creates a default RCSGetResponse.
static RCSGetResponse separate()
Creates a RCSGetResponse for the separate response.
This class provides factory methods to create the response for a received set request.
Definition: RCSResponse.h:168
bool isSeparate() const
Returns whether it is a separate response.
static RCSGetResponse create(int errorCode)
Creates a RCSGetResponse with error code passed.
static RCSSetResponse separate()
Creates a RCSSetResponse for a separate response.