Commit fe556250 authored by gejun's avatar gejun

add a lot of override

parent e2c9d6a7
......@@ -88,7 +88,7 @@ private:
int Initialize();
// Remove the accepted socket `sock' from inside
virtual void BeforeRecycle(Socket* sock);
void BeforeRecycle(Socket* sock) override;
bthread_keytable_pool_t* _keytable_pool; // owned by Server
Status _status;
......
......@@ -86,7 +86,7 @@ class FunctionClosure0 : public ::google::protobuf::Closure {
: function_(function), self_deleting_(self_deleting) {}
~FunctionClosure0() {}
void Run() {
void Run() override {
bool needs_delete = self_deleting_; // read in case callback deletes
function_();
if (needs_delete) delete this;
......
......@@ -59,9 +59,9 @@ class DefaultClusterRecoverPolicy : public ClusterRecoverPolicy {
public:
DefaultClusterRecoverPolicy(int64_t min_working_instances, int64_t hold_seconds);
void StartRecover();
bool DoReject(const std::vector<ServerId>& server_list);
bool StopRecoverIfNecessary();
void StartRecover() override;
bool DoReject(const std::vector<ServerId>& server_list) override;
bool StopRecoverIfNecessary() override;
private:
uint64_t GetUsableServerCount(int64_t now_ms, const std::vector<ServerId>& server_list);
......
......@@ -336,7 +336,7 @@ public:
// call the final "done" callback.
// Note: Reaching deadline of the RPC would not affect this function, which means
// even if deadline has been reached, this function may still return false.
bool IsCanceled() const;
bool IsCanceled() const override;
// Asks that the given callback be called when the RPC is canceled or the
// connection has broken. The callback will always be called exactly once.
......@@ -345,7 +345,7 @@ public:
// when NotifyOnCancel() is called, the callback will be called immediately.
//
// NotifyOnCancel() must be called no more than once per request.
void NotifyOnCancel(google::protobuf::Closure* callback);
void NotifyOnCancel(google::protobuf::Closure* callback) override;
// Returns the authenticated result. NULL if there is no authentication
const AuthContext* auth_context() const { return _auth_context; }
......@@ -437,7 +437,7 @@ public:
// Resets the Controller to its initial state so that it may be reused in
// a new call. Must NOT be called while an RPC is in progress.
void Reset() {
void Reset() override {
ResetNonPods();
ResetPods();
}
......@@ -448,18 +448,18 @@ public:
// as well if the protocol is HTTP. If you want to overwrite the
// status_code, call http_response().set_status_code() after SetFailed()
// (rather than before SetFailed)
void SetFailed(const std::string& reason);
void SetFailed(const std::string& reason) override;
void SetFailed(int error_code, const char* reason_fmt, ...)
__attribute__ ((__format__ (__printf__, 3, 4)));
// After a call has finished, returns true if the RPC call failed.
// The response to Channel is undefined when Failed() is true.
// Calling Failed() before a call has finished is undefined.
bool Failed() const;
bool Failed() const override;
// If Failed() is true, return description of the errors.
// NOTE: ErrorText() != berror(ErrorCode()).
std::string ErrorText() const;
std::string ErrorText() const override;
// Last error code. Equals 0 iff Failed() is false.
// If there's retry, latter code overwrites former one.
......@@ -557,7 +557,7 @@ private:
void ResetPods();
void ResetNonPods();
void StartCancel();
void StartCancel() override;
// Using fixed start_realtime_us (microseconds since the Epoch) gives
// more accurate deadline.
......
......@@ -93,7 +93,7 @@ public:
, _indent(indent, ' ')
{}
protected:
virtual int overflow(int ch) {
int overflow(int ch) override {
if (_is_at_start_of_line && ch != '\n' ) {
_dest->sputn(_indent.data(), _indent.size());
}
......
......@@ -51,7 +51,7 @@ public:
int Expose(const butil::StringPiece& prefix);
// Describe internal vars, used by /status
void Describe(std::ostream &os, const DescribeOptions&) const;
void Describe(std::ostream &os, const DescribeOptions&) const override;
// Current max_concurrency of the method.
int MaxConcurrency() const { return _cl ? _cl->MaxConcurrency() : 0; }
......
......@@ -28,19 +28,19 @@ namespace policy {
class ConsulNamingService : public NamingService {
private:
int RunNamingService(const char* service_name,
NamingServiceActions* actions);
NamingServiceActions* actions) override;
int GetServers(const char* service_name,
std::vector<ServerNode>* servers);
void Describe(std::ostream& os, const DescribeOptions&) const;
void Describe(std::ostream& os, const DescribeOptions&) const override;
NamingService* New() const;
NamingService* New() const override;
int DegradeToOtherServiceIfNeeded(const char* service_name,
std::vector<ServerNode>* servers);
void Destroy();
void Destroy() override;
private:
Channel _channel;
......
......@@ -30,13 +30,13 @@ public:
private:
int GetServers(const char *service_name,
std::vector<ServerNode>* servers);
std::vector<ServerNode>* servers) override;
void Describe(std::ostream& os, const DescribeOptions&) const;
void Describe(std::ostream& os, const DescribeOptions&) const override;
NamingService* New() const;
NamingService* New() const override;
void Destroy();
void Destroy() override;
private:
std::unique_ptr<char[]> _aux_buf;
......
......@@ -27,16 +27,16 @@ class FileNamingService : public NamingService {
friend class ConsulNamingService;
private:
int RunNamingService(const char* service_name,
NamingServiceActions* actions);
NamingServiceActions* actions) override;
int GetServers(const char *service_name,
std::vector<ServerNode>* servers);
void Describe(std::ostream& os, const DescribeOptions&) const;
void Describe(std::ostream& os, const DescribeOptions&) const override;
NamingService* New() const;
NamingService* New() const override;
void Destroy();
void Destroy() override;
};
} // namespace policy
......
......@@ -26,19 +26,19 @@ namespace policy {
class ListNamingService : public NamingService {
private:
int RunNamingService(const char* service_name,
NamingServiceActions* actions);
NamingServiceActions* actions) override;
// We don't need a dedicated bthread to run this static NS.
bool RunNamingServiceReturnsQuickly() { return true; }
bool RunNamingServiceReturnsQuickly() override { return true; }
int GetServers(const char *service_name,
std::vector<ServerNode>* servers);
void Describe(std::ostream& os, const DescribeOptions& options) const;
void Describe(std::ostream& os, const DescribeOptions& options) const override;
NamingService* New() const;
NamingService* New() const override;
void Destroy();
void Destroy() override;
};
} // namespace policy
......
......@@ -29,13 +29,13 @@ namespace policy {
class RemoteFileNamingService : public PeriodicNamingService {
private:
int GetServers(const char* service_name,
std::vector<ServerNode>* servers);
std::vector<ServerNode>* servers) override;
void Describe(std::ostream& os, const DescribeOptions&) const;
void Describe(std::ostream& os, const DescribeOptions&) const override;
NamingService* New() const;
NamingService* New() const override;
void Destroy();
void Destroy() override;
private:
std::unique_ptr<Channel> _channel;
......
......@@ -51,9 +51,9 @@ struct SampledRequest : public bvar::Collected
butil::IOBuf request;
// Implement methods of Sampled.
void dump_and_destroy(size_t round);
void destroy();
bvar::CollectorSpeedLimit* speed_limit() {
void dump_and_destroy(size_t round) override;
void destroy() override;
bvar::CollectorSpeedLimit* speed_limit() override {
extern bvar::CollectorSpeedLimit g_rpc_dump_sl;
return &g_rpc_dump_sl;
}
......
......@@ -65,9 +65,9 @@ struct SampledContention : public bvar::Collected {
void* stack[26]; // backtrace.
// Implement bvar::Collected
void dump_and_destroy(size_t round);
void destroy();
bvar::CollectorSpeedLimit* speed_limit() { return &g_cp_sl; }
void dump_and_destroy(size_t round) override;
void destroy() override;
bvar::CollectorSpeedLimit* speed_limit() override { return &g_cp_sl; }
// For combining samples with hashmap.
size_t hash_code() const {
......
......@@ -34,7 +34,7 @@ class ExitException : public std::exception {
public:
explicit ExitException(void* value) : _value(value) {}
~ExitException() throw() {}
const char* what() const throw() {
const char* what() const throw() override {
return "ExitException";
}
void* value() const {
......
......@@ -588,14 +588,14 @@ public:
virtual ~IOBufAsSnappySource() {}
// Return the number of bytes left to read from the source
virtual size_t Available() const;
size_t Available() const override;
// Peek at the next flat region of the source.
virtual const char* Peek(size_t* len);
const char* Peek(size_t* len) override;
// Skip the next n bytes. Invalidates any buffer returned by
// a previous call to Peek().
virtual void Skip(size_t n);
void Skip(size_t n) override;
private:
const butil::IOBuf* _buf;
......@@ -609,10 +609,10 @@ public:
virtual ~IOBufAsSnappySink() {}
// Append "bytes[0,n-1]" to this.
virtual void Append(const char* bytes, size_t n);
void Append(const char* bytes, size_t n) override;
// Returns a writable buffer of the specified length for appending.
virtual char* GetAppendBuffer(size_t length, char* scratch);
char* GetAppendBuffer(size_t length, char* scratch) override;
private:
char* _cur_buf;
......
......@@ -764,7 +764,7 @@ public:
}
bool OnLogMessage(int severity, const char* file, int line,
const butil::StringPiece& content) {
const butil::StringPiece& content) override {
// There's a copy here to concatenate prefix and content. Since
// DefaultLogSink is hardly used right now, the copy is irrelevant.
// A LogSink focused on performance should also be able to handle
......
......@@ -321,7 +321,7 @@ BUTIL_EXPORT LogSink* SetLogSink(LogSink* sink);
class StringSink : public LogSink, public std::string {
public:
bool OnLogMessage(int severity, const char* file, int line,
const butil::StringPiece& log_content);
const butil::StringPiece& log_content) override;
private:
butil::Lock _lock;
};
......@@ -857,8 +857,8 @@ public:
explicit CharArrayStreamBuf() : _data(NULL), _size(0) {}
~CharArrayStreamBuf();
virtual int overflow(int ch);
virtual int sync();
int overflow(int ch) override;
int sync() override;
void reset();
private:
......
......@@ -148,9 +148,9 @@ class ByteArraySource : public Source {
public:
ByteArraySource(const char* p, size_t n) : ptr_(p), left_(n) { }
virtual ~ByteArraySource();
virtual size_t Available() const;
virtual const char* Peek(size_t* len);
virtual void Skip(size_t n);
size_t Available() const override;
const char* Peek(size_t* len) override;
void Skip(size_t n) override;
private:
const char* ptr_;
size_t left_;
......@@ -161,14 +161,14 @@ class UncheckedByteArraySink : public Sink {
public:
explicit UncheckedByteArraySink(char* dest) : dest_(dest) { }
virtual ~UncheckedByteArraySink();
virtual void Append(const char* data, size_t n);
virtual char* GetAppendBuffer(size_t len, char* scratch);
virtual char* GetAppendBufferVariable(
void Append(const char* data, size_t n) override;
char* GetAppendBuffer(size_t len, char* scratch) override;
char* GetAppendBufferVariable(
size_t min_size, size_t desired_size_hint, char* scratch,
size_t scratch_size, size_t* allocated_size);
virtual void AppendAndTakeOwnership(
size_t scratch_size, size_t* allocated_size) override;
void AppendAndTakeOwnership(
char* bytes, size_t n, void (*deleter)(void*, const char*, size_t),
void *deleter_arg);
void *deleter_arg) override;
// Return the current output pointer so that a caller can see how
// many bytes were produced.
......
......@@ -37,11 +37,11 @@ public:
void shrink();
protected:
virtual int overflow(int ch);
virtual int sync();
int overflow(int ch) override;
int sync() override;
std::streampos seekoff(std::streamoff off,
std::ios_base::seekdir way,
std::ios_base::openmode which);
std::ios_base::openmode which) override;
private:
google::protobuf::io::ZeroCopyOutputStream* _zero_copy_stream;
......
......@@ -97,7 +97,7 @@ public:
}
~ReducerSampler() {}
void take_sample() {
void take_sample() override {
// Make _q ready.
// If _window_size is larger than what _q can hold, e.g. a larger
// Window<> is created after running of sampler, make _q larger.
......
......@@ -34,11 +34,10 @@ public:
// Calling hide() in dtor manually is a MUST required by Variable.
~GFlag() { hide(); }
// Implement Variable::describe() and Variable::get_value().
void describe(std::ostream& os, bool quote_string) const;
void describe(std::ostream& os, bool quote_string) const override;
#ifdef BAIDU_INTERNAL
void get_value(boost::any* value) const;
void get_value(boost::any* value) const override;
#endif
// Get value of the gflag.
......
......@@ -37,8 +37,8 @@ class CDF : public Variable {
public:
explicit CDF(PercentileWindow* w);
~CDF();
void describe(std::ostream& os, bool quote_string) const;
int describe_series(std::ostream& os, const SeriesOptions& options) const;
void describe(std::ostream& os, bool quote_string) const override;
int describe_series(std::ostream& os, const SeriesOptions& options) const override;
private:
PercentileWindow* _w;
};
......
......@@ -57,7 +57,7 @@ public:
~SeriesSampler() {
delete _vector_names;
}
void take_sample() { _series.append(_owner->get_value()); }
void take_sample() override { _series.append(_owner->get_value()); }
void describe(std::ostream& os) { _series.describe(os, _vector_names); }
void set_vector_names(const std::string& names) {
if (_vector_names == NULL) {
......@@ -120,12 +120,12 @@ public:
return -1;
}
void describe(std::ostream& os, bool /*quote_string*/) const {
void describe(std::ostream& os, bool /*quote_string*/) const override {
os << get_value();
}
#ifdef BAIDU_INTERNAL
void get_value(boost::any* value) const {
void get_value(boost::any* value) const override {
if (_getfn) {
*value = _getfn(_arg);
} else {
......@@ -217,7 +217,7 @@ public:
hide();
}
void describe(std::ostream& os, bool quote_string) const {
void describe(std::ostream& os, bool quote_string) const override {
if (quote_string) {
if (_print) {
os << '"';
......
......@@ -154,7 +154,7 @@ public:
AddStat op() const { return AddStat(); }
MinusStat inv_op() const { return MinusStat(); }
void describe(std::ostream& os, bool /*quote_string*/) const {
void describe(std::ostream& os, bool /*quote_string*/) const override {
os << get_value();
}
......
......@@ -74,7 +74,7 @@ public:
SeriesSampler(Reducer* owner, const Op& op)
: _owner(owner), _series(op) {}
~SeriesSampler() {}
void take_sample() { _series.append(_owner->get_value()); }
void take_sample() override { _series.append(_owner->get_value()); }
void describe(std::ostream& os) { _series.describe(os, NULL); }
private:
Reducer* _owner;
......@@ -125,8 +125,7 @@ public:
// Returns the reduced value before reset.
T reset() { return _combiner.reset_all_agents(); }
// Implement Variable::describe() and Variable::get_value().
void describe(std::ostream& os, bool quote_string) const {
void describe(std::ostream& os, bool quote_string) const override {
if (butil::is_same<T, std::string>::value && quote_string) {
os << '"' << get_value() << '"';
} else {
......@@ -135,7 +134,7 @@ public:
}
#ifdef BAIDU_INTERNAL
void get_value(boost::any* value) const { *value = get_value(); }
void get_value(boost::any* value) const override { *value = get_value(); }
#endif
// True if this reducer is constructed successfully.
......@@ -153,7 +152,7 @@ public:
return _sampler;
}
int describe_series(std::ostream& os, const SeriesOptions& options) const {
int describe_series(std::ostream& os, const SeriesOptions& options) const override {
if (_series_sampler == NULL) {
return 1;
}
......@@ -166,7 +165,7 @@ public:
protected:
int expose_impl(const butil::StringPiece& prefix,
const butil::StringPiece& name,
DisplayFilter display_filter) {
DisplayFilter display_filter) override {
const int rc = Variable::expose_impl(prefix, name, display_filter);
if (rc == 0 &&
_series_sampler == NULL &&
......
......@@ -52,13 +52,12 @@ public:
// Calling hide() manually is a MUST required by Variable.
~Status() { hide(); }
// Implement Variable::describe() and Variable::get_value().
void describe(std::ostream& os, bool /*quote_string*/) const {
void describe(std::ostream& os, bool /*quote_string*/) const override {
os << get_value();
}
#ifdef BAIDU_INTERNAL
void get_value(boost::any* value) const {
void get_value(boost::any* value) const override {
butil::AutoLock guard(_lock);
*value = _value;
}
......@@ -122,13 +121,12 @@ public:
}
}
// Implement Variable::describe() and Variable::get_value().
void describe(std::ostream& os, bool /*quote_string*/) const {
void describe(std::ostream& os, bool /*quote_string*/) const override {
os << get_value();
}
#ifdef BAIDU_INTERNAL
void get_value(boost::any* value) const {
void get_value(boost::any* value) const override {
*value = get_value();
}
#endif
......@@ -197,7 +195,7 @@ public:
~Status() { hide(); }
void describe(std::ostream& os, bool quote_string) const {
void describe(std::ostream& os, bool quote_string) const override {
if (quote_string) {
os << '"' << get_value() << '"';
} else {
......@@ -211,7 +209,7 @@ public:
}
#ifdef BAIDU_INTERNAL
void get_value(boost::any* value) const {
void get_value(boost::any* value) const override {
*value = get_value();
}
#endif
......
......@@ -315,8 +315,8 @@ public:
explicit CharArrayStreamBuf() : _data(NULL), _size(0) {}
~CharArrayStreamBuf();
virtual int overflow(int ch);
virtual int sync();
int overflow(int ch) override;
int sync() override;
void reset();
butil::StringPiece data() {
return butil::StringPiece(pbase(), pptr() - pbase());
......@@ -586,7 +586,7 @@ public:
_fp = NULL;
}
}
bool dump(const std::string& name, const butil::StringPiece& desc) {
bool dump(const std::string& name, const butil::StringPiece& desc) override {
if (_fp == NULL) {
butil::File::Error error;
butil::FilePath dir = butil::FilePath(_filename).DirName();
......@@ -647,7 +647,7 @@ public:
dumpers.clear();
}
bool dump(const std::string& name, const butil::StringPiece& desc) {
bool dump(const std::string& name, const butil::StringPiece& desc) override {
for (size_t i = 0; i < dumpers.size() - 1; ++i) {
if (dumpers[i].second->match(name)) {
return dumpers[i].first->dump(name, desc);
......
......@@ -56,7 +56,7 @@ public:
SeriesSampler(WindowBase* owner, R* var)
: _owner(owner), _series(Op(var)) {}
~SeriesSampler() {}
void take_sample() {
void take_sample() override {
if (series_freq == SERIES_IN_SECOND) {
// Get one-second window value for PerSecond<>, otherwise the
// "smoother" plot may hide peaks.
......@@ -108,8 +108,7 @@ public:
value_type get_value() const { return get_value(_window_size); }
// Implement Variable::describe() and Variable::get_value().
void describe(std::ostream& os, bool quote_string) const {
void describe(std::ostream& os, bool quote_string) const override {
if (butil::is_same<value_type, std::string>::value && quote_string) {
os << '"' << get_value() << '"';
} else {
......@@ -118,7 +117,7 @@ public:
}
#ifdef BAIDU_INTERNAL
void get_value(boost::any* value) const { *value = get_value(); }
void get_value(boost::any* value) const override { *value = get_value(); }
#endif
time_t window_size() const { return _window_size; }
......@@ -219,7 +218,7 @@ public:
this->expose_as(prefix, name);
}
virtual value_type get_value(time_t window_size) const {
value_type get_value(time_t window_size) const override {
detail::Sample<value_type> s;
this->get_span(window_size, &s);
// We may test if the multiplication overflows and use integral ops
......
......@@ -1345,7 +1345,7 @@ public:
bool Generate(const google::protobuf::FileDescriptor* file,
const std::string& parameter,
google::protobuf::compiler::GeneratorContext*,
std::string* error) const;
std::string* error) const override;
};
bool McpackToProtobuf::Generate(const google::protobuf::FileDescriptor* file,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment