Files
flipper/xplat/Flipper/FlipperState.h
Rain ⁣ aa649ff48f standardize C-like MIT copyright headers throughout fbsource
Summary:
`/*` is the standard throughout open source code. For example, Firefox uses single /*: https://hg.mozilla.org/mozilla-central/file/21d22b2f541258d3d1cf96c7ba5ad73e96e616b5/gfx/ipc/CompositorWidgetVsyncObserver.cpp#l3

In addition, Rust considers `/**` to be a doc comment (similar to Javadoc) and having such a comment at the beginning of the file causes `rustc` to barf.

Note that some JavaScript tooling requires `/**`. This is OK since JavaScript files were not covered by the linter in the first place, but it would be good to have that tooling fixed too.

Reviewed By: zertosh

Differential Revision: D15640366

fbshipit-source-id: b4ed4599071516364d6109720750d6a43304c089
2019-06-06 19:40:28 -07:00

57 lines
1.4 KiB
C++

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree.
*/
#pragma once
#include <memory>
#include <string>
#include <vector>
#include <map>
class FlipperStep;
class FlipperStateUpdateListener;
namespace facebook {
namespace flipper {
enum State { success, in_progress, failed };
class StateElement {
public:
StateElement(std::string name, State state): name_(name), state_(state) {};
std::string name_;
State state_;
};
}
}
class FlipperState {
friend FlipperStep;
public:
FlipperState();
void setUpdateListener(std::shared_ptr<FlipperStateUpdateListener>);
std::string getState();
std::vector<facebook::flipper::StateElement> getStateElements();
/* To record a state update, call start() with the name of the step to get a
FlipperStep object. Call complete on this to register it successful,
the absense of the completion call when it is destructed will register as a
step failure. */
std::shared_ptr<FlipperStep> start(std::string step);
private:
void success(std::string);
void failed(std::string, std::string);
void started(std::string);
std::shared_ptr<FlipperStateUpdateListener> mListener = nullptr;
std::string logs;
std::vector<std::string> insertOrder;
std::map<std::string, facebook::flipper::State> stateMap;
};