ClientClassDefPtr
TestConfigBackendDHCPv4::getClientClass4(const db::ServerSelector& server_selector,
const std::string& name) const {
- auto client_class = classes_.findClass(name);
+ ClientClassDefPtr client_class;
+ for (auto c : classes_) {
+ if (c->getName() == name) {
+ client_class = c;
+ break;
+ }
+ }
if (!client_class || server_selector.amAny()) {
return (client_class);
}
TestConfigBackendDHCPv4::getAllClientClasses4(const db::ServerSelector& server_selector) const {
auto tags = server_selector.getTags();
ClientClassDictionary all_classes;
- for (auto client_class : *classes_.getClasses()) {
+ for (auto client_class : classes_) {
auto non_const_client_class = boost::const_pointer_cast<ClientClassDef>(client_class);
if (server_selector.amAny()) {
all_classes.addClass(non_const_client_class);
const boost::posix_time::ptime& modification_time) const {
auto tags = server_selector.getTags();
ClientClassDictionary modified_classes;
- for (auto client_class : *classes_.getClasses()) {
+ for (auto client_class : classes_) {
if (client_class->getModificationTime() >= modification_time) {
auto non_const_client_class = boost::const_pointer_cast<ClientClassDef>(client_class);
bool got = false;
void
TestConfigBackendDHCPv4::createUpdateClientClass4(const db::ServerSelector& server_selector,
const ClientClassDefPtr& client_class,
- const std::string&) {
+ const std::string& follow_class_name) {
+ int follow_class_index = -1;
+ if (!follow_class_name.empty()) {
+ for (auto i = 0; i < classes_.size(); ++i) {
+ if (classes_[i]->getName() == follow_class_name) {
+ follow_class_index = i;
+ break;
+ }
+ }
+ if (follow_class_index < 0) {
+ isc_throw(BadValue, "class " << follow_class_name << " does not exist");
+
+ }
+ }
+
mergeServerTags(client_class, server_selector);
- auto existing_class = classes_.findClass(client_class->getName());
- if (existing_class) {
- classes_.removeClass(client_class->getName());
+ int existing_class_index = -1;
+ for (auto i = 0; i < classes_.size(); ++i) {
+ if (classes_[i]->getName() == client_class->getName()) {
+ existing_class_index = i;
+ break;
+ }
}
+
auto non_const_client_class = boost::const_pointer_cast<ClientClassDef>(client_class);
- classes_.addClass(non_const_client_class);
+
+ if (follow_class_index < 0) {
+ if (existing_class_index >= 0) {
+ classes_[existing_class_index] = non_const_client_class;
+ } else {
+ classes_.push_back(non_const_client_class);
+ }
+ } else {
+ if (existing_class_index < 0) {
+ classes_.insert(classes_.begin() + follow_class_index + 1, client_class);
+ } else {
+ classes_.erase(classes_.begin() + existing_class_index);
+ classes_.insert(classes_.begin() + follow_class_index + 1, client_class);
+ }
+ }
}
AuditEntryCollection
uint64_t
TestConfigBackendDHCPv4::deleteClientClass4(const db::ServerSelector& server_selector,
const std::string& name) {
- auto existing_class = classes_.findClass(name);
+ ClientClassDefPtr existing_class;
+ auto c = classes_.begin();
+ for (; c != classes_.end(); ++c) {
+ if ((*c)->getName() == name) {
+ existing_class = (*c);
+ break;
+ }
+ }
if (!existing_class) {
return (0);
}
return (0);
}
}
- classes_.removeClass(name);
+ classes_.erase(c);
return (1);
}
uint64_t
TestConfigBackendDHCPv4::deleteAllClientClasses4(const db::ServerSelector& server_selector) {
- std::list<std::string> class_names;
- for (auto client_class : (*classes_.getClasses())) {
+ uint64_t count = 0;
+ for (auto c = classes_.begin(); c != classes_.end(); ++c) {
+ auto client_class = *c;
if (server_selector.amAny()) {
- class_names.push_back(client_class->getName());
+ c = classes_.erase(c);
+ ++count;
continue;
}
if (server_selector.amUnassigned()) {
if (client_class->getServerTags().empty()) {
- class_names.push_back(client_class->getName());
+ c = classes_.erase(c);
+ ++count;
}
continue;
}
auto tags = server_selector.getTags();
for (auto tag : tags) {
if (client_class->hasServerTag(ServerTag(tag))) {
- class_names.push_back(client_class->getName());
+ c = classes_.erase(c);
+ ++count;
got = true;
break;
}
continue;
}
if (client_class->hasAllServerTag()) {
- class_names.push_back(client_class->getName());
+ c = classes_.erase(c);
+ ++count;
}
}
- // Erase client classes.
- for (auto name : class_names) {
- classes_.removeClass(name);
- }
- return (class_names.size());
+ return (count);
}
uint64_t