xref: /aosp_15_r20/external/federated-compute/fcp/secagg/client/secagg_client_completed_state.h (revision 14675a029014e728ec732f129a32e299b2da0601)
1 /*
2  * Copyright 2018 Google LLC
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef FCP_SECAGG_CLIENT_SECAGG_CLIENT_COMPLETED_STATE_H_
18 #define FCP_SECAGG_CLIENT_SECAGG_CLIENT_COMPLETED_STATE_H_
19 
20 #include <memory>
21 #include <string>
22 
23 #include "fcp/secagg/client/secagg_client_state.h"
24 #include "fcp/secagg/client/state_transition_listener_interface.h"
25 
26 namespace fcp {
27 namespace secagg {
28 
29 // This class represents the Completed state for a client, meaning the
30 // client has either sent its final message or received a message indicating
31 // success from the server.
32 //
33 // There are no transitions out of this state.
34 
35 class SecAggClientCompletedState : public SecAggClientState {
36  public:
37   // As a terminal state, this State does not need to store any specific
38   // information except the sender (to ensure it does not go out of scope
39   // unexpectedly).
40   explicit SecAggClientCompletedState(
41       std::unique_ptr<SendToServerInterface> sender,
42       std::unique_ptr<StateTransitionListenerInterface> transition_listener);
43 
44   ~SecAggClientCompletedState() override;
45 
46   // Returns true from this state.
47   bool IsCompletedSuccessfully() const override;
48 
49   // Returns the name of this state, "COMPLETED".
50   std::string StateName() const override;
51 };
52 
53 }  // namespace secagg
54 }  // namespace fcp
55 
56 #endif  // FCP_SECAGG_CLIENT_SECAGG_CLIENT_COMPLETED_STATE_H_
57