Commit fe556250 authored by gejun's avatar gejun

add a lot of override

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