mirror of https://github.com/Icinga/icinga2.git
Removed dependency on boost/uuid.
This commit is contained in:
parent
cf18ac6deb
commit
10dff1d8c1
|
@ -18,13 +18,11 @@
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#include "base/utility.h"
|
#include "base/utility.h"
|
||||||
|
#include "base/convert.h"
|
||||||
#include "base/application.h"
|
#include "base/application.h"
|
||||||
#include "base/logger_fwd.h"
|
#include "base/logger_fwd.h"
|
||||||
#include "base/exception.h"
|
#include "base/exception.h"
|
||||||
#include <mmatch.h>
|
#include <mmatch.h>
|
||||||
#include <boost/uuid/uuid.hpp>
|
|
||||||
#include <boost/uuid/uuid_generators.hpp>
|
|
||||||
#include <boost/uuid/uuid_io.hpp>
|
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
#include <boost/function.hpp>
|
#include <boost/function.hpp>
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
|
@ -276,14 +274,33 @@ Utility::LoadExtensionLibrary(const String& library)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a new UUID.
|
* Generates a new unique ID.
|
||||||
*
|
*
|
||||||
* @returns The new UUID in text form.
|
* @returns The new unique ID.
|
||||||
*/
|
*/
|
||||||
String Utility::NewUUID(void)
|
String Utility::NewUniqueID(void)
|
||||||
{
|
{
|
||||||
boost::uuids::uuid uuid = boost::uuids::random_generator()();
|
static boost::mutex mutex;
|
||||||
return boost::lexical_cast<String>(uuid);
|
static int next_id = 0;
|
||||||
|
|
||||||
|
/* I'd much rather use UUIDs but RHEL is way too cool to have
|
||||||
|
* a semi-recent version of boost. Yay. */
|
||||||
|
|
||||||
|
String id;
|
||||||
|
|
||||||
|
char buf[128];
|
||||||
|
if (gethostname(buf, sizeof(buf)) == 0)
|
||||||
|
id = String(buf) + "-";
|
||||||
|
|
||||||
|
id += Convert::ToString((long)Utility::GetTime()) + "-";
|
||||||
|
|
||||||
|
{
|
||||||
|
boost::mutex::scoped_lock lock(mutex);
|
||||||
|
id += Convert::ToString(next_id);
|
||||||
|
next_id++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -53,7 +53,7 @@ public:
|
||||||
|
|
||||||
static void Sleep(double timeout);
|
static void Sleep(double timeout);
|
||||||
|
|
||||||
static String NewUUID(void);
|
static String NewUniqueID(void);
|
||||||
|
|
||||||
static bool Glob(const String& pathSpec, const boost::function<void (const String&)>& callback);
|
static bool Glob(const String& pathSpec, const boost::function<void (const String&)>& callback);
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ using namespace icinga;
|
||||||
ConfigCompilerContext *ConfigCompilerContext::m_Context = NULL;
|
ConfigCompilerContext *ConfigCompilerContext::m_Context = NULL;
|
||||||
|
|
||||||
ConfigCompilerContext::ConfigCompilerContext(void)
|
ConfigCompilerContext::ConfigCompilerContext(void)
|
||||||
: m_Unit(Utility::NewUUID()), m_Flags(0)
|
: m_Unit(Utility::NewUniqueID()), m_Flags(0)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
void ConfigCompilerContext::AddItem(const ConfigItem::Ptr& item)
|
void ConfigCompilerContext::AddItem(const ConfigItem::Ptr& item)
|
||||||
|
|
|
@ -81,7 +81,7 @@ String Service::AddComment(CommentType entryType, const String& author,
|
||||||
m_Comments = comments;
|
m_Comments = comments;
|
||||||
}
|
}
|
||||||
|
|
||||||
String id = Utility::NewUUID();
|
String id = Utility::NewUniqueID();
|
||||||
comments->Set(id, comment);
|
comments->Set(id, comment);
|
||||||
|
|
||||||
Touch("comments");
|
Touch("comments");
|
||||||
|
|
|
@ -96,7 +96,7 @@ String Service::AddDowntime(const String& author, const String& comment,
|
||||||
m_Downtimes = downtimes;
|
m_Downtimes = downtimes;
|
||||||
}
|
}
|
||||||
|
|
||||||
String id = Utility::NewUUID();
|
String id = Utility::NewUniqueID();
|
||||||
downtimes->Set(id, downtime);
|
downtimes->Set(id, downtime);
|
||||||
|
|
||||||
Touch("downtimes");
|
Touch("downtimes");
|
||||||
|
|
Loading…
Reference in New Issue