Commit 2f9d1aa9 authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰
Browse files

[5577] Changes after review:

 - copyright updated
 - ensureHookLibsVectorSize is now private
 - methods renamed as suggested by Marcin
parent 70fe4301
// Copyright (C) 2013-2017 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2013-2018 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
......@@ -67,7 +67,7 @@ CalloutManager::registerCallout(const std::string& name, CalloutPtr callout) {
checkLibraryIndex(current_library_);
// New hooks could have been registered since the manager was constructed.
ensureVectorSize();
ensureHookLibsVectorSize();
// Get the index associated with this hook (validating the name in the
// process).
......@@ -237,7 +237,7 @@ CalloutManager::deregisterCallout(const std::string& name, CalloutPtr callout) {
checkLibraryIndex(current_library_);
// New hooks could have been registered since the manager was constructed.
ensureVectorSize();
ensureHookLibsVectorSize();
// Get the index associated with this hook (validating the name in the
// process).
......@@ -288,7 +288,7 @@ bool
CalloutManager::deregisterAllCallouts(const std::string& name) {
// New hooks could have been registered since the manager was constructed.
ensureVectorSize();
ensureHookLibsVectorSize();
// Get the index associated with this hook (validating the name in the
// process).
......@@ -325,7 +325,7 @@ void
CalloutManager::registerCommandHook(const std::string& command_name) {
// New hooks could have been registered since the manager was constructed.
ensureVectorSize();
ensureHookLibsVectorSize();
ServerHooks& hooks = ServerHooks::getServerHooks();
int hook_index = hooks.findIndex(ServerHooks::commandToHookName(command_name));
......@@ -342,7 +342,7 @@ CalloutManager::registerCommandHook(const std::string& command_name) {
}
void
CalloutManager::ensureVectorSize() {
CalloutManager::ensureHookLibsVectorSize() {
ServerHooks& hooks = ServerHooks::getServerHooks();
if (hooks.getCount() > hook_vector_.size()) {
// Uh oh, there are more hook points that our vector allows.
......
// Copyright (C) 2013-2017 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2013-2018 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
......@@ -365,12 +365,15 @@ public:
return (post_library_handle_);
}
//@}
/// @brief Return number of currently available hooks
size_t getVectorSize() const {
size_t getHookLibsVectorSize() const {
return (hook_vector_.size());
}
private:
/// @brief This method checks whether the hook_vector_ size is suffucient
/// and extends it if necessary.
///
......@@ -390,11 +393,8 @@ public:
/// is registered. It checks whether the vector size is sufficient and
/// extends it if necessary. It is safe to call it multiple times. It
/// may grow the vector size, but will never shrink it.
void ensureVectorSize();
void ensureHookLibsVectorSize();
//@}
private:
/// @brief Check library index
///
/// Ensures that the current library index is valid. This is called by
......
// Copyright (C) 2013-2017 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2013-2018 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
......@@ -922,7 +922,7 @@ TEST_F(CalloutManagerTest, LibraryHandleRegisterCommandHandler) {
// This test checks if the CalloutManager can adjust its own hook_vector_ size.
TEST_F(CalloutManagerTest, VectorSize) {
size_t s = getCalloutManager()->getVectorSize();
size_t s = getCalloutManager()->getHookLibsVectorSize();
ServerHooks& hooks = ServerHooks::getServerHooks();
......@@ -935,7 +935,7 @@ TEST_F(CalloutManagerTest, VectorSize) {
// The vector size should have been increased by one, because there's
// one new hook point now.
EXPECT_EQ(s + 1, getCalloutManager()->getVectorSize());
EXPECT_EQ(s + 1, getCalloutManager()->getHookLibsVectorSize());
}
......
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