Use nullptr instead of <Type>::Ptr()

This commit is contained in:
Gunnar Beutner 2017-11-30 08:36:35 +01:00
parent 3c60fbf75d
commit 325e4a2fb9
72 changed files with 117 additions and 115 deletions

View File

@ -706,7 +706,7 @@ ConfigObject::Ptr ConfigObject::GetObject(const String& type, const String& name
ConfigType *ctype = dynamic_cast<ConfigType *>(ptype.get());
if (!ctype)
return ConfigObject::Ptr();
return nullptr;
return ctype->GetObject(name);
}

View File

@ -33,7 +33,7 @@ ConfigObject::Ptr ConfigType::GetObject(const String& name) const
auto nt = m_ObjectMap.find(name);
if (nt == m_ObjectMap.end())
return ConfigObject::Ptr();
return nullptr;
return nt->second;
}

View File

@ -61,7 +61,7 @@ public:
static void EmitArray(std::ostream& fp, int indentLevel, const Array::Ptr& val);
static void EmitArrayItems(std::ostream& fp, int indentLevel, const Array::Ptr& val);
static void EmitScope(std::ostream& fp, int indentLevel, const Dictionary::Ptr& val,
const Array::Ptr& imports = Array::Ptr(), bool splitDot = false);
const Array::Ptr& imports = nullptr, bool splitDot = false);
static void EmitValue(std::ostream& fp, int indentLevel, const Value& val);
static void EmitRaw(std::ostream& fp, const String& val);
static void EmitIndent(std::ostream& fp, int indentLevel);

View File

@ -39,7 +39,7 @@ String ObjectType::GetName(void) const
Type::Ptr ObjectType::GetBaseType(void) const
{
return Type::Ptr();
return nullptr;
}
int ObjectType::GetAttributes(void) const

View File

@ -34,7 +34,7 @@ String PrimitiveType::GetName(void) const
Type::Ptr PrimitiveType::GetBaseType(void) const
{
if (m_Base == "None")
return Type::Ptr();
return nullptr;
else
return Type::GetByName(m_Base);
}

View File

@ -66,7 +66,7 @@ public:
static const std::deque<Process::Ptr>::size_type MaxTasksPerThread = 512;
Process(const Arguments& arguments, const Dictionary::Ptr& extraEnvironment = Dictionary::Ptr());
Process(const Arguments& arguments, const Dictionary::Ptr& extraEnvironment = nullptr);
~Process(void);
void SetTimeout(double timeout);

View File

@ -405,7 +405,7 @@ ConfigObject::Ptr ScriptUtils::GetObject(const Value& vtype, const String& name)
ConfigType *ctype = dynamic_cast<ConfigType *>(ptype.get());
if (!ctype)
return ConfigObject::Ptr();
return nullptr;
return ctype->GetObject(name);
}

View File

@ -55,7 +55,7 @@ static Object::Ptr SerializeObject(const Object::Ptr& input, int attributeTypes)
Type::Ptr type = input->GetReflectionType();
if (!type)
return Object::Ptr();
return nullptr;
Dictionary::Ptr fields = new Dictionary();
@ -168,7 +168,7 @@ Value icinga::Serialize(const Value& value, int attributeTypes)
Value icinga::Deserialize(const Value& value, bool safe_mode, int attributeTypes)
{
return Deserialize(Object::Ptr(), value, safe_mode, attributeTypes);
return Deserialize(nullptr, value, safe_mode, attributeTypes);
}
Value icinga::Deserialize(const Object::Ptr& object, const Value& value, bool safe_mode, int attributeTypes)

View File

@ -49,12 +49,12 @@ Type::Ptr Type::GetByName(const String& name)
Dictionary::Ptr typesNS = ScriptGlobal::Get("Types", &Empty);
if (!typesNS)
return Type::Ptr();
return nullptr;
Value ptype = typesNS->Get(name);
if (!ptype.IsObjectType<Type>())
return Type::Ptr();
return nullptr;
return ptype;
}

View File

@ -100,7 +100,7 @@ Type::Ptr Value::GetReflectionType(void) const
case ValueObject:
return boost::get<Object::Ptr>(m_Value)->GetReflectionType();
default:
return Type::Ptr();
return nullptr;
}
}

View File

@ -55,6 +55,9 @@ public:
inline Value(void)
{ }
inline Value(std::nullptr_t)
{ }
inline Value(int value)
: m_Value(double(value))
{ }

View File

@ -130,7 +130,7 @@ CLICommand::Ptr CLICommand::GetByName(const std::vector<String>& name)
auto it = GetRegistry().find(name);
if (it == GetRegistry().end())
return CLICommand::Ptr();
return nullptr;
return it->second;
}

View File

@ -49,7 +49,7 @@ private:
class I2_CONFIG_API ActivationScope
{
public:
ActivationScope(const ActivationContext::Ptr& context = ActivationContext::Ptr());
ActivationScope(const ActivationContext::Ptr& context = nullptr);
~ActivationScope(void);
ActivationContext::Ptr GetContext(void) const;

View File

@ -185,7 +185,7 @@ ConfigObject::Ptr ConfigItem::Commit(bool discard)
BOOST_THROW_EXCEPTION(ScriptError("Type '" + GetType() + "' does not exist.", m_DebugInfo));
if (IsAbstract())
return ConfigObject::Ptr();
return nullptr;
ConfigObject::Ptr dobj = static_pointer_cast<ConfigObject>(type->Instantiate(std::vector<Value>()));
@ -211,7 +211,7 @@ ConfigObject::Ptr ConfigItem::Commit(bool discard)
m_IgnoredItems.push_back(m_DebugInfo.Path);
}
return ConfigObject::Ptr();
return nullptr;
}
throw;
@ -263,7 +263,7 @@ ConfigObject::Ptr ConfigItem::Commit(bool discard)
m_IgnoredItems.push_back(m_DebugInfo.Path);
}
return ConfigObject::Ptr();
return nullptr;
}
ex.SetDebugHint(dhint);
@ -282,7 +282,7 @@ ConfigObject::Ptr ConfigItem::Commit(bool discard)
m_IgnoredItems.push_back(m_DebugInfo.Path);
}
return ConfigObject::Ptr();
return nullptr;
}
throw;
@ -378,12 +378,12 @@ ConfigItem::Ptr ConfigItem::GetByTypeAndName(const Type::Ptr& type, const String
auto it = m_Items.find(type);
if (it == m_Items.end())
return ConfigItem::Ptr();
return nullptr;
auto it2 = it->second.find(name);
if (it2 == it->second.end())
return ConfigItem::Ptr();
return nullptr;
return it2->second;
}

View File

@ -36,7 +36,7 @@ namespace icinga
struct DebugHint
{
public:
DebugHint(const Dictionary::Ptr& hints = Dictionary::Ptr())
DebugHint(const Dictionary::Ptr& hints = nullptr)
: m_Hints(hints)
{ }

View File

@ -152,7 +152,7 @@ public:
NameComposer *nc = dynamic_cast<NameComposer *>(type.get());
if (nc)
checkName = nc->MakeName(name, Dictionary::Ptr());
checkName = nc->MakeName(name, nullptr);
}
if (!checkName.IsEmpty()) {

View File

@ -45,5 +45,5 @@ Dictionary::Ptr CommandDbObject::GetConfigFields(void) const
Dictionary::Ptr CommandDbObject::GetStatusFields(void) const
{
return Dictionary::Ptr();
return nullptr;
}

View File

@ -354,7 +354,7 @@ DbObject::Ptr DbObject::GetOrCreateByObject(const ConfigObject::Ptr& object)
DbType::Ptr dbtype = DbType::GetByName(object->GetReflectionType()->GetName());
if (!dbtype)
return DbObject::Ptr();
return nullptr;
Service::Ptr service;
String name1, name2;

View File

@ -68,7 +68,7 @@ DbType::Ptr DbType::GetByName(const String& name)
auto it = GetTypes().find(typeName);
if (it == GetTypes().end())
return DbType::Ptr();
return nullptr;
return it->second;
}
@ -82,7 +82,7 @@ DbType::Ptr DbType::GetByID(long tid)
return kv.second;
}
return DbType::Ptr();
return nullptr;
}
DbObject::Ptr DbType::GetOrCreateObjectByName(const String& name1, const String& name2)

View File

@ -47,5 +47,5 @@ Dictionary::Ptr HostGroupDbObject::GetConfigFields(void) const
Dictionary::Ptr HostGroupDbObject::GetStatusFields(void) const
{
return Dictionary::Ptr();
return nullptr;
}

View File

@ -46,5 +46,5 @@ Dictionary::Ptr ServiceGroupDbObject::GetConfigFields(void) const
Dictionary::Ptr ServiceGroupDbObject::GetStatusFields(void) const
{
return Dictionary::Ptr();
return nullptr;
}

View File

@ -44,5 +44,5 @@ Dictionary::Ptr UserGroupDbObject::GetConfigFields(void) const
Dictionary::Ptr UserGroupDbObject::GetStatusFields(void) const
{
return Dictionary::Ptr();
return nullptr;
}

View File

@ -684,12 +684,12 @@ Dictionary::Ptr IdoMysqlConnection::FetchRow(const IdoMysqlResult& result)
row = mysql_fetch_row(result.get());
if (!row)
return Dictionary::Ptr();
return nullptr;
lengths = mysql_fetch_lengths(result.get());
if (!lengths)
return Dictionary::Ptr();
return nullptr;
Dictionary::Ptr dict = new Dictionary();

View File

@ -522,7 +522,7 @@ Dictionary::Ptr IdoPgsqlConnection::FetchRow(const IdoPgsqlResult& result, int r
AssertOnWorkQueue();
if (row >= PQntuples(result.get()))
return Dictionary::Ptr();
return nullptr;
int columns = PQnfields(result.get());

View File

@ -54,7 +54,7 @@ void Demo::DemoTimerHandler(void)
ApiListener::Ptr listener = ApiListener::GetInstance();
if (listener) {
MessageOrigin::Ptr origin = new MessageOrigin();
listener->RelayMessage(origin, ConfigObject::Ptr(), message, true);
listener->RelayMessage(origin, nullptr, message, true);
Log(LogInformation, "Demo", "Sent demo::HelloWorld message");
}
}

View File

@ -165,7 +165,7 @@ Dictionary::Ptr ApiActions::SendCustomNotification(const ConfigObject::Ptr& obje
checkable->SetForceNextNotification(true);
Checkable::OnNotificationsRequested(checkable, NotificationCustom, checkable->GetLastCheckResult(),
HttpUtility::GetLastParameter(params, "author"), HttpUtility::GetLastParameter(params, "comment"), MessageOrigin::Ptr());
HttpUtility::GetLastParameter(params, "author"), HttpUtility::GetLastParameter(params, "comment"), nullptr);
return ApiActions::CreateResult(200, "Successfully sent custom notification for object '" + checkable->GetName() + "'.");
}

View File

@ -48,7 +48,7 @@ public:
static Dictionary::Ptr GenerateTicket(const ConfigObject::Ptr& object, const Dictionary::Ptr& params);
private:
static Dictionary::Ptr CreateResult(int code, const String& status, const Dictionary::Ptr& additional = Dictionary::Ptr());
static Dictionary::Ptr CreateResult(int code, const String& status, const Dictionary::Ptr& additional = nullptr);
};
}

View File

@ -371,7 +371,7 @@ void Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrig
if (!in_downtime && !was_flapping && is_flapping) {
/* FlappingStart notifications happen on state changes, not in downtimes */
if (!IsPaused())
OnNotificationsRequested(this, NotificationFlappingStart, cr, "", "", MessageOrigin::Ptr());
OnNotificationsRequested(this, NotificationFlappingStart, cr, "", "", nullptr);
Log(LogNotice, "Checkable")
<< "Flapping Start: Checkable '" << GetName() << "' started flapping (Current flapping value "
@ -381,7 +381,7 @@ void Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrig
} else if (!in_downtime && was_flapping && !is_flapping) {
/* FlappingEnd notifications are independent from state changes, must not happen in downtine */
if (!IsPaused())
OnNotificationsRequested(this, NotificationFlappingEnd, cr, "", "", MessageOrigin::Ptr());
OnNotificationsRequested(this, NotificationFlappingEnd, cr, "", "", nullptr);
Log(LogNotice, "Checkable")
<< "Flapping Stop: Checkable '" << GetName() << "' stopped flapping (Current flapping value "
@ -392,7 +392,7 @@ void Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrig
if (send_notification && !is_flapping) {
if (!IsPaused())
OnNotificationsRequested(this, recovery ? NotificationRecovery : NotificationProblem, cr, "", "", MessageOrigin::Ptr());
OnNotificationsRequested(this, recovery ? NotificationRecovery : NotificationProblem, cr, "", "", nullptr);
}
}

View File

@ -80,7 +80,7 @@ bool Checkable::IsReachable(DependencyType dt, Dependency::Ptr *failedDependency
if (host && host->GetState() != HostUp && host->GetStateType() == StateTypeHard) {
if (failedDependency)
*failedDependency = Dependency::Ptr();
*failedDependency = nullptr;
return false;
}
@ -96,7 +96,7 @@ bool Checkable::IsReachable(DependencyType dt, Dependency::Ptr *failedDependency
}
if (failedDependency)
*failedDependency = Dependency::Ptr();
*failedDependency = nullptr;
return true;
}

View File

@ -128,7 +128,7 @@ void Checkable::AcknowledgeProblem(const String& author, const String& comment,
SetAcknowledgementExpiry(expiry);
if (notify && !IsPaused())
OnNotificationsRequested(this, NotificationAcknowledgement, GetLastCheckResult(), author, comment, MessageOrigin::Ptr());
OnNotificationsRequested(this, NotificationAcknowledgement, GetLastCheckResult(), author, comment, nullptr);
OnAcknowledgementSet(this, author, comment, type, notify, persistent, expiry, origin);
}
@ -173,7 +173,7 @@ void Checkable::NotifyDowntimeInternal(const Downtime::Ptr& downtime)
Checkable::Ptr checkable = downtime->GetCheckable();
if (!checkable->IsPaused())
OnNotificationsRequested(checkable, NotificationDowntimeStart, checkable->GetLastCheckResult(), downtime->GetAuthor(), downtime->GetComment(), MessageOrigin::Ptr());
OnNotificationsRequested(checkable, NotificationDowntimeStart, checkable->GetLastCheckResult(), downtime->GetAuthor(), downtime->GetComment(), nullptr);
}
void Checkable::NotifyDowntimeEnd(const Downtime::Ptr& downtime)
@ -185,7 +185,7 @@ void Checkable::NotifyDowntimeEnd(const Downtime::Ptr& downtime)
Checkable::Ptr checkable = downtime->GetCheckable();
if (!checkable->IsPaused())
OnNotificationsRequested(checkable, NotificationDowntimeEnd, checkable->GetLastCheckResult(), downtime->GetAuthor(), downtime->GetComment(), MessageOrigin::Ptr());
OnNotificationsRequested(checkable, NotificationDowntimeEnd, checkable->GetLastCheckResult(), downtime->GetAuthor(), downtime->GetComment(), nullptr);
}
void Checkable::ValidateCheckInterval(double value, const ValidationUtils& utils)

View File

@ -98,8 +98,8 @@ public:
AcknowledgementType GetAcknowledgement(void);
void AcknowledgeProblem(const String& author, const String& comment, AcknowledgementType type, bool notify = true, bool persistent = false, double expiry = 0, const MessageOrigin::Ptr& origin = MessageOrigin::Ptr());
void ClearAcknowledgement(const MessageOrigin::Ptr& origin = MessageOrigin::Ptr());
void AcknowledgeProblem(const String& author, const String& comment, AcknowledgementType type, bool notify = true, bool persistent = false, double expiry = 0, const MessageOrigin::Ptr& origin = nullptr);
void ClearAcknowledgement(const MessageOrigin::Ptr& origin = nullptr);
virtual int GetSeverity(void) const override;
@ -110,7 +110,7 @@ public:
long GetSchedulingOffset(void);
void SetSchedulingOffset(long offset);
void UpdateNextCheck(const MessageOrigin::Ptr& origin = MessageOrigin::Ptr());
void UpdateNextCheck(const MessageOrigin::Ptr& origin = nullptr);
bool HasBeenChecked(void) const;
virtual bool IsStateOK(ServiceState state) = 0;
@ -121,9 +121,9 @@ public:
static void UpdateStatistics(const CheckResult::Ptr& cr, CheckableType type);
void ExecuteRemoteCheck(const Dictionary::Ptr& resolvedMacros = Dictionary::Ptr());
void ExecuteRemoteCheck(const Dictionary::Ptr& resolvedMacros = nullptr);
void ExecuteCheck();
void ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrigin::Ptr& origin = MessageOrigin::Ptr());
void ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrigin::Ptr& origin = nullptr);
Endpoint::Ptr GetCommandEndpoint(void) const;
@ -174,7 +174,7 @@ public:
void ResetNotificationNumbers(void);
/* Event Handler */
void ExecuteEventHandler(const Dictionary::Ptr& resolvedMacros = Dictionary::Ptr(),
void ExecuteEventHandler(const Dictionary::Ptr& resolvedMacros = nullptr,
bool useResolvedMacros = false);
intrusive_ptr<EventCommand> GetEventCommand(void) const;

View File

@ -38,7 +38,7 @@ public:
DECLARE_OBJECTNAME(CheckCommand);
virtual void Execute(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
const Dictionary::Ptr& resolvedMacros = Dictionary::Ptr(),
const Dictionary::Ptr& resolvedMacros = nullptr,
bool useResolvedMacros = false);
};

View File

@ -704,7 +704,7 @@ void ClusterEvents::SendNotificationsHandler(const Checkable::Ptr& checkable, No
params->Set("author", author);
params->Set("text", text);
listener->RelayMessage(origin, ConfigObject::Ptr(), message, true);
listener->RelayMessage(origin, nullptr, message, true);
}
Value ClusterEvents::SendNotificationsAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params)
@ -798,7 +798,7 @@ void ClusterEvents::NotificationSentUserHandler(const Notification::Ptr& notific
message->Set("method", "event::NotificationSentUser");
message->Set("params", params);
listener->RelayMessage(origin, ConfigObject::Ptr(), message, true);
listener->RelayMessage(origin, nullptr, message, true);
}
Value ClusterEvents::NotificationSentUserAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params)
@ -914,7 +914,7 @@ void ClusterEvents::NotificationSentToAllUsersHandler(const Notification::Ptr& n
message->Set("method", "event::NotificationSentToAllUsers");
message->Set("params", params);
listener->RelayMessage(origin, ConfigObject::Ptr(), message, true);
listener->RelayMessage(origin, nullptr, message, true);
}
Value ClusterEvents::NotificationSentToAllUsersAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params)

View File

@ -181,7 +181,7 @@ String Comment::AddComment(const Checkable::Ptr& checkable, CommentType entryTyp
if (!zone.IsEmpty())
attrs->Set("zone", zone);
String config = ConfigObjectUtility::CreateObjectConfig(Comment::TypeInstance, fullName, true, Array::Ptr(), attrs);
String config = ConfigObjectUtility::CreateObjectConfig(Comment::TypeInstance, fullName, true, nullptr, attrs);
Array::Ptr errors = new Array();

View File

@ -50,9 +50,9 @@ public:
static String AddComment(const intrusive_ptr<Checkable>& checkable, CommentType entryType,
const String& author, const String& text, bool persistent, double expireTime,
const String& id = String(), const MessageOrigin::Ptr& origin = MessageOrigin::Ptr());
const String& id = String(), const MessageOrigin::Ptr& origin = nullptr);
static void RemoveComment(const String& id, const MessageOrigin::Ptr& origin = MessageOrigin::Ptr());
static void RemoveComment(const String& id, const MessageOrigin::Ptr& origin = nullptr);
static String GetCommentIDFromLegacyID(int id);

View File

@ -72,7 +72,7 @@ class Comment : ConfigObject < CommentNameComposer
}}}
navigate {{{
if (GetServiceName().IsEmpty())
return Service::Ptr();
return nullptr;
Host::Ptr host = Host::GetByName(GetHostName());
return host->GetServiceByShortName(GetServiceName());

View File

@ -368,7 +368,7 @@ Dictionary::Ptr CompatUtility::GetCustomAttributeConfig(const CustomVarObject::P
Dictionary::Ptr vars = object->GetVars();
if (!vars)
return Dictionary::Ptr();
return nullptr;
return vars;
}

View File

@ -60,7 +60,7 @@ class Dependency : CustomVarObject < DependencyNameComposer
}}}
navigate {{{
if (GetChildServiceName().IsEmpty())
return Service::Ptr();
return nullptr;
Host::Ptr host = Host::GetByName(GetChildHostName());
return host->GetServiceByShortName(GetChildServiceName());
@ -87,7 +87,7 @@ class Dependency : CustomVarObject < DependencyNameComposer
}}}
navigate {{{
if (GetParentServiceName().IsEmpty())
return Service::Ptr();
return nullptr;
Host::Ptr host = Host::GetByName(GetParentHostName());
return host->GetServiceByShortName(GetParentServiceName());

View File

@ -255,7 +255,7 @@ String Downtime::AddDowntime(const Checkable::Ptr& checkable, const String& auth
if (!zone.IsEmpty())
attrs->Set("zone", zone);
String config = ConfigObjectUtility::CreateObjectConfig(Downtime::TypeInstance, fullName, true, Array::Ptr(), attrs);
String config = ConfigObjectUtility::CreateObjectConfig(Downtime::TypeInstance, fullName, true, nullptr, attrs);
Array::Ptr errors = new Array();

View File

@ -57,9 +57,9 @@ public:
const String& comment, double startTime, double endTime, bool fixed,
const String& triggeredBy, double duration, const String& scheduledDowntime = String(),
const String& scheduledBy = String(), const String& id = String(),
const MessageOrigin::Ptr& origin = MessageOrigin::Ptr());
const MessageOrigin::Ptr& origin = nullptr);
static void RemoveDowntime(const String& id, bool cancelled, bool expired = false, const MessageOrigin::Ptr& origin = MessageOrigin::Ptr());
static void RemoveDowntime(const String& id, bool cancelled, bool expired = false, const MessageOrigin::Ptr& origin = nullptr);
void TriggerDowntime(void);

View File

@ -59,7 +59,7 @@ class Downtime : ConfigObject < DowntimeNameComposer
}}}
navigate {{{
if (GetServiceName().IsEmpty())
return Service::Ptr();
return nullptr;
Host::Ptr host = Host::GetByName(GetHostName());
return host->GetServiceByShortName(GetServiceName());

View File

@ -38,7 +38,7 @@ public:
DECLARE_OBJECTNAME(EventCommand);
virtual void Execute(const Checkable::Ptr& checkable,
const Dictionary::Ptr& resolvedMacros = Dictionary::Ptr(),
const Dictionary::Ptr& resolvedMacros = nullptr,
bool useResolvedMacros = false);
};

View File

@ -1358,7 +1358,7 @@ void ExternalCommandProcessor::SendCustomHostNotification(double, const std::vec
}
Checkable::OnNotificationsRequested(host, NotificationCustom,
host->GetLastCheckResult(), arguments[2], arguments[3], MessageOrigin::Ptr());
host->GetLastCheckResult(), arguments[2], arguments[3], nullptr);
}
void ExternalCommandProcessor::SendCustomSvcNotification(double, const std::vector<String>& arguments)
@ -1378,7 +1378,7 @@ void ExternalCommandProcessor::SendCustomSvcNotification(double, const std::vect
}
Service::OnNotificationsRequested(service, NotificationCustom,
service->GetLastCheckResult(), arguments[3], arguments[4], MessageOrigin::Ptr());
service->GetLastCheckResult(), arguments[3], arguments[4], nullptr);
}
void ExternalCommandProcessor::DelayHostNotification(double, const std::vector<String>& arguments)

View File

@ -144,7 +144,7 @@ Service::Ptr Host::GetServiceByShortName(const Value& name)
return it->second;
}
return Service::Ptr();
return nullptr;
} else if (name.IsObjectType<Dictionary>()) {
Dictionary::Ptr dict = name;
String short_name;

View File

@ -451,7 +451,7 @@ Dictionary::Ptr LegacyTimePeriod::FindNextSegment(const String& daydef, const St
} while (tsiter < tsend);
}
return Dictionary::Ptr();
return nullptr;
}
Array::Ptr LegacyTimePeriod::ScriptFunc(const TimePeriod::Ptr& tp, double begin, double end)

View File

@ -291,7 +291,7 @@ Value MacroProcessor::InternalResolveMacros(const String& str, const ResolverLis
for (const Value& value : arr) {
if (value.IsScalar()) {
resolved_arr->Add(InternalResolveMacros(value,
resolvers, cr, missingMacro, EscapeCallback(), Dictionary::Ptr(),
resolvers, cr, missingMacro, EscapeCallback(), nullptr,
false, recursionLevel + 1));
} else
resolved_arr->Add(value);
@ -300,7 +300,7 @@ Value MacroProcessor::InternalResolveMacros(const String& str, const ResolverLis
resolved_macro = resolved_arr;
} else if (resolved_macro.IsString()) {
resolved_macro = InternalResolveMacros(resolved_macro,
resolvers, cr, missingMacro, EscapeCallback(), Dictionary::Ptr(),
resolvers, cr, missingMacro, EscapeCallback(), nullptr,
false, recursionLevel + 1);
}
}

View File

@ -41,9 +41,9 @@ public:
typedef std::vector<ResolverSpec> ResolverList;
static Value ResolveMacros(const Value& str, const ResolverList& resolvers,
const CheckResult::Ptr& cr = CheckResult::Ptr(), String *missingMacro = NULL,
const CheckResult::Ptr& cr = nullptr, String *missingMacro = NULL,
const EscapeCallback& escapeFn = EscapeCallback(),
const Dictionary::Ptr& resolvedMacros = Dictionary::Ptr(),
const Dictionary::Ptr& resolvedMacros = nullptr,
bool useResolvedMacros = false, int recursionLevel = 0);
static Value ResolveArguments(const Value& command, const Dictionary::Ptr& arguments,

View File

@ -431,7 +431,7 @@ void Notification::BeginExecuteNotification(NotificationType type, const CheckRe
notifiedProblemUsers->Clear();
/* used in db_ido for notification history */
Service::OnNotificationSentToAllUsers(this, checkable, allNotifiedUsers, type, cr, author, text, MessageOrigin::Ptr());
Service::OnNotificationSentToAllUsers(this, checkable, allNotifiedUsers, type, cr, author, text, nullptr);
}
bool Notification::CheckNotificationUserFilters(NotificationType type, const User::Ptr& user, bool force, bool reminder)
@ -518,7 +518,7 @@ void Notification::ExecuteNotificationHelper(NotificationType type, const User::
command->Execute(this, user, cr, type, author, text);
/* required by compatlogger */
Service::OnNotificationSentToUser(this, GetCheckable(), user, type, cr, author, text, command->GetName(), MessageOrigin::Ptr());
Service::OnNotificationSentToUser(this, GetCheckable(), user, type, cr, author, text, command->GetName(), nullptr);
Log(LogInformation, "Notification")
<< "Completed sending '" << NotificationTypeToStringInternal(type)

View File

@ -79,7 +79,7 @@ class Notification : CustomVarObject < NotificationNameComposer
}}}
navigate {{{
if (GetServiceName().IsEmpty())
return Service::Ptr();
return nullptr;
Host::Ptr host = Host::GetByName(GetHostName());
return host->GetServiceByShortName(GetServiceName());

View File

@ -42,7 +42,7 @@ public:
virtual Dictionary::Ptr Execute(const intrusive_ptr<Notification>& notification,
const User::Ptr& user, const CheckResult::Ptr& cr, const NotificationType& type,
const String& author, const String& comment,
const Dictionary::Ptr& resolvedMacros = Dictionary::Ptr(),
const Dictionary::Ptr& resolvedMacros = nullptr,
bool useResolvedMacros = false);
};

View File

@ -51,7 +51,7 @@ Service::Ptr ObjectUtils::GetService(const Value& host, const String& name)
hostObj = Host::GetByName(host);
if (!hostObj)
return Service::Ptr();
return nullptr;
return hostObj->GetServiceByShortName(name);
}
@ -66,7 +66,7 @@ Array::Ptr ObjectUtils::GetServices(const Value& host)
hostObj = Host::GetByName(host);
if (!hostObj)
return Array::Ptr();
return nullptr;
return Array::FromVector(hostObj->GetServices());
}

View File

@ -58,7 +58,7 @@ class ScheduledDowntime : CustomVarObject < ScheduledDowntimeNameComposer
}}}
navigate {{{
if (GetServiceName().IsEmpty())
return Service::Ptr();
return nullptr;
Host::Ptr host = Host::GetByName(GetHostName());
return host->GetServiceByShortName(GetServiceName());

View File

@ -111,7 +111,7 @@ Service::Ptr Service::GetByNamePair(const String& hostName, const String& servic
Host::Ptr host = Host::GetByName(hostName);
if (!host)
return Service::Ptr();
return nullptr;
return host->GetServiceByShortName(serviceName);
} else {
@ -274,6 +274,6 @@ std::pair<Host::Ptr, Service::Ptr> icinga::GetHostService(const Checkable::Ptr&
if (service)
return std::make_pair(service->GetHost(), service);
else
return std::make_pair(static_pointer_cast<Host>(checkable), Service::Ptr());
return std::make_pair(static_pointer_cast<Host>(checkable), nullptr);
}

View File

@ -211,7 +211,7 @@ Object::Ptr HostsTable::HostGroupAccessor(const Value& row, LivestatusGroupByTyp
if (groupByType == LivestatusGroupByHostGroup)
return groupByObject;
return Object::Ptr();
return nullptr;
}
Value HostsTable::NameAccessor(const Value& row)
@ -328,7 +328,7 @@ Value HostsTable::NotesExpandedAccessor(const Value& row)
{ "icinga", IcingaApplication::GetInstance() }
};
return MacroProcessor::ResolveMacros(host->GetNotes(), resolvers, CheckResult::Ptr());
return MacroProcessor::ResolveMacros(host->GetNotes(), resolvers);
}
Value HostsTable::NotesUrlAccessor(const Value& row)

View File

@ -320,7 +320,7 @@ Filter::Ptr LivestatusQuery::ParseFilter(const String& params, unsigned long& fr
tokens.push_back("");
if (tokens.size() < 3)
return Filter::Ptr();
return nullptr;
bool negate = false;
String attr = tokens[0];

View File

@ -117,7 +117,7 @@ Object::Ptr LogTable::HostAccessor(const Value& row, const Column::ObjectAccesso
String host_name = static_cast<Dictionary::Ptr>(row)->Get("host_name");
if (host_name.IsEmpty())
return Object::Ptr();
return nullptr;
return Host::GetByName(host_name);
}
@ -128,7 +128,7 @@ Object::Ptr LogTable::ServiceAccessor(const Value& row, const Column::ObjectAcce
String service_description = static_cast<Dictionary::Ptr>(row)->Get("service_description");
if (service_description.IsEmpty() || host_name.IsEmpty())
return Object::Ptr();
return nullptr;
return Service::GetByNamePair(host_name, service_description);
}
@ -138,7 +138,7 @@ Object::Ptr LogTable::ContactAccessor(const Value& row, const Column::ObjectAcce
String contact_name = static_cast<Dictionary::Ptr>(row)->Get("contact_name");
if (contact_name.IsEmpty())
return Object::Ptr();
return nullptr;
return User::GetByName(contact_name);
}
@ -148,7 +148,7 @@ Object::Ptr LogTable::CommandAccessor(const Value& row, const Column::ObjectAcce
String command_name = static_cast<Dictionary::Ptr>(row)->Get("command_name");
if (command_name.IsEmpty())
return Object::Ptr();
return nullptr;
CheckCommand::Ptr check_command = CheckCommand::GetByName(command_name);
if (!check_command) {
@ -156,7 +156,7 @@ Object::Ptr LogTable::CommandAccessor(const Value& row, const Column::ObjectAcce
if (!event_command) {
NotificationCommand::Ptr notification_command = NotificationCommand::GetByName(command_name);
if (!notification_command)
return Object::Ptr();
return nullptr;
else
return notification_command;
} else

View File

@ -206,7 +206,7 @@ Object::Ptr ServicesTable::HostAccessor(const Value& row, const Column::ObjectAc
Service::Ptr svc = static_cast<Service::Ptr>(service);
if (!svc)
return Object::Ptr();
return nullptr;
return svc->GetHost();
}
@ -220,7 +220,7 @@ Object::Ptr ServicesTable::ServiceGroupAccessor(const Value& row, LivestatusGrou
if (groupByType == LivestatusGroupByServiceGroup)
return groupByObject;
return Object::Ptr();
return nullptr;
}
Object::Ptr ServicesTable::HostGroupAccessor(const Value& row, LivestatusGroupByType groupByType, const Object::Ptr& groupByObject)
@ -232,7 +232,7 @@ Object::Ptr ServicesTable::HostGroupAccessor(const Value& row, LivestatusGroupBy
if (groupByType == LivestatusGroupByHostGroup)
return groupByObject;
return Object::Ptr();
return nullptr;
}
Value ServicesTable::ShortNameAccessor(const Value& row)

View File

@ -281,7 +281,7 @@ Object::Ptr StateHistTable::HostAccessor(const Value& row, const Column::ObjectA
String host_name = static_cast<Dictionary::Ptr>(row)->Get("host_name");
if (host_name.IsEmpty())
return Object::Ptr();
return nullptr;
return Host::GetByName(host_name);
}
@ -292,7 +292,7 @@ Object::Ptr StateHistTable::ServiceAccessor(const Value& row, const Column::Obje
String service_description = static_cast<Dictionary::Ptr>(row)->Get("service_description");
if (service_description.IsEmpty() || host_name.IsEmpty())
return Object::Ptr();
return nullptr;
return Service::GetByNamePair(host_name, service_description);
}

View File

@ -84,7 +84,7 @@ Table::Ptr Table::GetByName(const String& name, const String& compat_log_path, c
else if (name == "zones")
return new ZonesTable();
return Table::Ptr();
return nullptr;
}
void Table::AddColumn(const String& name, const Column& column)

View File

@ -69,7 +69,7 @@ bool ActionsHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& reques
}
} else {
FilterUtility::CheckPermission(user, permission);
objs.push_back(ConfigObject::Ptr());
objs.push_back(nullptr);
}
Array::Ptr results = new Array();

View File

@ -322,7 +322,7 @@ void ApiClient::AutocompleteScript(const String& session, const String& command,
req->AddHeader("Accept", "application/json");
m_Connection->SubmitRequest(req, std::bind(AutocompleteScriptHttpCompletionCallback, _1, _2, callback));
} catch (const std::exception& ex) {
callback(boost::current_exception(), Array::Ptr());
callback(boost::current_exception(), nullptr);
}
}
@ -363,6 +363,6 @@ void ApiClient::AutocompleteScriptHttpCompletionCallback(HttpRequest& request,
callback(boost::exception_ptr(), suggestions);
} catch (const std::exception& ex) {
callback(boost::current_exception(), Array::Ptr());
callback(boost::current_exception(), nullptr);
}
}

View File

@ -425,7 +425,7 @@ void ApiListener::SendRuntimeConfigObjects(const JsonRpcConnection::Ptr& aclient
continue;
/* send the config object to the connected client */
UpdateConfigObject(object, MessageOrigin::Ptr(), aclient);
UpdateConfigObject(object, nullptr, aclient);
}
}

View File

@ -279,7 +279,7 @@ Endpoint::Ptr ApiListener::GetMaster(void) const
Zone::Ptr zone = Zone::GetLocalZone();
if (!zone)
return Endpoint::Ptr();
return nullptr;
std::vector<String> names;
@ -568,10 +568,10 @@ void ApiListener::SyncClient(const JsonRpcConnection::Ptr& aclient, const Endpoi
Log(LogInformation, "ApiListener")
<< "Requesting new certificate for this Icinga instance from endpoint '" << endpoint->GetName() << "'.";
JsonRpcConnection::SendCertificateRequest(aclient, MessageOrigin::Ptr(), String());
JsonRpcConnection::SendCertificateRequest(aclient, nullptr, String());
if (Utility::PathExists(ApiListener::GetCertificateRequestsDir()))
Utility::Glob(ApiListener::GetCertificateRequestsDir() + "/*.json", std::bind(&JsonRpcConnection::SendCertificateRequest, aclient, MessageOrigin::Ptr(), _1), GlobFile);
Utility::Glob(ApiListener::GetCertificateRequestsDir() + "/*.json", std::bind(&JsonRpcConnection::SendCertificateRequest, aclient, nullptr, _1), GlobFile);
}
/* Make sure that the config updates are synced

View File

@ -176,9 +176,9 @@ private:
/* configsync */
void UpdateConfigObject(const ConfigObject::Ptr& object, const MessageOrigin::Ptr& origin,
const JsonRpcConnection::Ptr& client = JsonRpcConnection::Ptr());
const JsonRpcConnection::Ptr& client = nullptr);
void DeleteConfigObject(const ConfigObject::Ptr& object, const MessageOrigin::Ptr& origin,
const JsonRpcConnection::Ptr& client = JsonRpcConnection::Ptr());
const JsonRpcConnection::Ptr& client = nullptr);
void SendRuntimeConfigObjects(const JsonRpcConnection::Ptr& aclient);
void SyncClient(const JsonRpcConnection::Ptr& aclient, const Endpoint::Ptr& endpoint, bool needSync);

View File

@ -32,5 +32,5 @@ ApiUser::Ptr ApiUser::GetByClientCN(const String& cn)
return user;
}
return ApiUser::Ptr();
return nullptr;
}

View File

@ -46,7 +46,7 @@ public:
static std::vector<String> GetPackages(void);
static bool PackageExists(const String& name);
static String CreateStage(const String& packageName, const Dictionary::Ptr& files = Dictionary::Ptr());
static String CreateStage(const String& packageName, const Dictionary::Ptr& files = nullptr);
static void DeleteStage(const String& packageName, const String& stageName);
static std::vector<String> GetStages(const String& packageName);
static String GetActiveStage(const String& packageName);

View File

@ -113,7 +113,7 @@ Endpoint::Ptr Endpoint::GetLocalEndpoint(void)
ApiListener::Ptr listener = ApiListener::GetInstance();
if (!listener)
return Endpoint::Ptr();
return nullptr;
return listener->GetLocalEndpoint();
}

View File

@ -115,11 +115,10 @@ Dictionary::Ptr EventQueue::WaitForEvent(void *client, double timeout)
}
if (!m_CV.timed_wait(lock, boost::posix_time::milliseconds(timeout * 1000)))
return Dictionary::Ptr();
return nullptr;
}
}
std::vector<EventQueue::Ptr> EventQueue::GetQueuesForType(const String& type)
{
EventQueueRegistry::ItemMap queues = EventQueueRegistry::GetInstance()->GetItems();

View File

@ -33,7 +33,7 @@ Type::Ptr FilterUtility::TypeFromPluralName(const String& pluralName)
String uname = pluralName;
boost::algorithm::to_lower(uname);
for (const Type::Ptr&type : Type::GetAllTypes()) {
for (const Type::Ptr& type : Type::GetAllTypes()) {
String pname = type->GetPluralName();
boost::algorithm::to_lower(pname);
@ -41,7 +41,7 @@ Type::Ptr FilterUtility::TypeFromPluralName(const String& pluralName)
return type;
}
return Type::Ptr();
return nullptr;
}
void ConfigObjectTargetProvider::FindTargets(const String& type, const std::function<void (const Value&)>& addTarget) const

View File

@ -82,7 +82,7 @@ void HttpServerConnection::Disconnect(void)
listener->RemoveHttpClient(this);
m_CurrentRequest.~HttpRequest();
new (&m_CurrentRequest) HttpRequest(Stream::Ptr());
new (&m_CurrentRequest) HttpRequest(nullptr);
m_Stream->Close();
}

View File

@ -215,7 +215,7 @@ delayed_request:
Utility::SaveJsonFile(requestPath, 0600, request);
JsonRpcConnection::SendCertificateRequest(JsonRpcConnection::Ptr(), origin, requestPath);
JsonRpcConnection::SendCertificateRequest(nullptr, origin, requestPath);
result->Set("status_code", 2);
result->Set("error", "Certificate request for CN '" + cn + "' is pending. Waiting for approval from the parent Icinga instance.");

View File

@ -139,7 +139,7 @@ Zone::Ptr Zone::GetLocalZone(void)
Endpoint::Ptr local = Endpoint::GetLocalEndpoint();
if (!local)
return Zone::Ptr();
return nullptr;
return local->GetZone();
}