aboutsummaryrefslogtreecommitdiffstats
path: root/config/src/vespa/config/frt/frtconfigresponse.cpp
blob: 523126ee8359db1e9bc3ae38e96dff79c972b061 (plain) (blame)
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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "frtconfigresponse.h"
#include <vespa/fnet/frt/rpcrequest.h>

namespace config {

FRTConfigResponse::FRTConfigResponse(FRT_RPCRequest * request)
    : _request(request),
      _responseState(EMPTY),
      _returnValues(_request->GetReturn())
{
    _request->internal_addref();
}

FRTConfigResponse::~FRTConfigResponse()
{
    _request->internal_subref();
}

bool
FRTConfigResponse::validateResponse()
{
    if (_request->IsError())
        _responseState = ERROR;
    if (_request->GetReturn()->GetNumValues() == 0)
        _responseState = EMPTY;
    if (_request->CheckReturnTypes(getResponseTypes().c_str())) {
        _returnValues = _request->GetReturn();
        _responseState = OK;
    }
    return (_responseState == OK);
}

bool
FRTConfigResponse::hasValidResponse() const
{
    return (_responseState == OK);
}

vespalib::string FRTConfigResponse::errorMessage() const { return _request->GetErrorMessage(); }
int FRTConfigResponse::errorCode() const { return _request->GetErrorCode(); }
bool FRTConfigResponse::isError() const { return _request->IsError(); }

} // namespace config