| 371 | } |
| 372 | |
| 373 | DbObject::Ptr DbObject::GetOrCreateByObject(const ConfigObject::Ptr& object) |
| 374 | { |
| 375 | std::unique_lock<std::mutex> lock(GetStaticMutex()); |
| 376 | |
| 377 | DbObject::Ptr dbobj = object->GetExtension("DbObject"); |
| 378 | |
| 379 | if (dbobj) |
| 380 | return dbobj; |
| 381 | |
| 382 | DbType::Ptr dbtype = DbType::GetByName(object->GetReflectionType()->GetName()); |
| 383 | |
| 384 | if (!dbtype) |
| 385 | return nullptr; |
| 386 | |
| 387 | Service::Ptr service; |
| 388 | String name1, name2; |
| 389 | |
| 390 | service = dynamic_pointer_cast<Service>(object); |
| 391 | |
| 392 | if (service) { |
| 393 | Host::Ptr host = service->GetHost(); |
| 394 | |
| 395 | name1 = service->GetHost()->GetName(); |
| 396 | name2 = service->GetShortName(); |
| 397 | } else { |
| 398 | if (object->GetReflectionType() == CheckCommand::TypeInstance || |
| 399 | object->GetReflectionType() == EventCommand::TypeInstance || |
| 400 | object->GetReflectionType() == NotificationCommand::TypeInstance) { |
| 401 | Command::Ptr command = dynamic_pointer_cast<Command>(object); |
| 402 | name1 = CompatUtility::GetCommandName(command); |
| 403 | } |
| 404 | else |
| 405 | name1 = object->GetName(); |
| 406 | } |
| 407 | |
| 408 | dbobj = dbtype->GetOrCreateObjectByName(name1, name2); |
| 409 | |
| 410 | dbobj->SetObject(object); |
| 411 | object->SetExtension("DbObject", dbobj); |
| 412 | |
| 413 | return dbobj; |
| 414 | } |
| 415 | |
| 416 | void DbObject::StateChangedHandler(const ConfigObject::Ptr& object) |
| 417 | { |
nothing calls this directly
no test coverage detected