mirror of https://github.com/Icinga/icinga2.git
parent
25da7a2291
commit
640136fbdb
|
@ -69,13 +69,13 @@ public:
|
|||
private:
|
||||
String m_Name;
|
||||
|
||||
typedef std::map<String, DynamicObject::Ptr, string_iless> ObjectMap;
|
||||
typedef std::map<String, DynamicObject::Ptr> ObjectMap;
|
||||
typedef std::vector<DynamicObject::Ptr> ObjectVector;
|
||||
|
||||
ObjectMap m_ObjectMap;
|
||||
ObjectVector m_ObjectVector;
|
||||
|
||||
typedef std::map<String, DynamicType::Ptr, string_iless> TypeMap;
|
||||
typedef std::map<String, DynamicType::Ptr> TypeMap;
|
||||
typedef std::vector<DynamicType::Ptr> TypeVector;
|
||||
|
||||
static TypeMap& InternalGetTypeMap(void);
|
||||
|
|
|
@ -151,30 +151,16 @@ struct string_iless : std::binary_function<String, String, bool>
|
|||
{
|
||||
bool operator()(const String& s1, const String& s2) const
|
||||
{
|
||||
return strcasecmp(s1.CStr(), s2.CStr()) < 0;
|
||||
return strcasecmp(s1.CStr(), s2.CStr()) < 0;
|
||||
|
||||
/* The "right" way would be to do this - however the
|
||||
* overhead is _massive_ due to the repeated non-inlined
|
||||
* function calls:
|
||||
/* The "right" way would be to do this - however the
|
||||
* overhead is _massive_ due to the repeated non-inlined
|
||||
* function calls:
|
||||
|
||||
return lexicographical_compare(s1.Begin(), s1.End(),
|
||||
s2.Begin(), s2.End(), boost::algorithm::is_iless());
|
||||
return lexicographical_compare(s1.Begin(), s1.End(),
|
||||
s2.Begin(), s2.End(), boost::algorithm::is_iless());
|
||||
|
||||
*/
|
||||
}
|
||||
};
|
||||
|
||||
struct pair_string_iless : std::binary_function<std::pair<String, String>, std::pair<String, String>, bool>
|
||||
{
|
||||
bool operator()(const std::pair<String, String>& p1, const std::pair<String, String>& p2) const
|
||||
{
|
||||
if (string_iless()(p1.first, p2.first))
|
||||
return true;
|
||||
|
||||
if (string_iless()(p2.first, p1.first))
|
||||
return false;
|
||||
|
||||
return string_iless()(p1.second, p2.second);
|
||||
*/
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ template<typename U, typename T>
|
|||
class Registry
|
||||
{
|
||||
public:
|
||||
typedef std::map<String, T, string_iless> ItemMap;
|
||||
typedef std::map<String, T> ItemMap;
|
||||
|
||||
static Registry<U, T> *GetInstance(void)
|
||||
{
|
||||
|
|
|
@ -144,8 +144,6 @@ DynamicObject::Ptr ConfigItem::Commit(void)
|
|||
{
|
||||
ASSERT(!OwnsLock());
|
||||
|
||||
String type, name;
|
||||
|
||||
Log(LogDebug, "base", "Commit called for ConfigItem Type=" + GetType() + ", Name=" + GetName());
|
||||
|
||||
/* Make sure the type is valid. */
|
||||
|
@ -154,7 +152,7 @@ DynamicObject::Ptr ConfigItem::Commit(void)
|
|||
if (!dtype)
|
||||
BOOST_THROW_EXCEPTION(std::runtime_error("Type '" + GetType() + "' does not exist."));
|
||||
|
||||
if (m_DynamicObject.lock() || dtype->GetObject(m_Name))
|
||||
if (dtype->GetObject(GetName()))
|
||||
BOOST_THROW_EXCEPTION(std::runtime_error("An object with type '" + GetType() + "' and name '" + GetName() + "' already exists."));
|
||||
|
||||
if (IsAbstract())
|
||||
|
@ -199,18 +197,6 @@ void ConfigItem::Register(void)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the DynamicObject that belongs to the configuration item.
|
||||
*
|
||||
* @returns The DynamicObject.
|
||||
*/
|
||||
DynamicObject::Ptr ConfigItem::GetDynamicObject(void) const
|
||||
{
|
||||
ObjectLock olock(this);
|
||||
|
||||
return m_DynamicObject.lock();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a configuration item by type and name.
|
||||
*
|
||||
|
|
|
@ -55,8 +55,6 @@ public:
|
|||
DynamicObject::Ptr Commit(void);
|
||||
void Register(void);
|
||||
|
||||
DynamicObject::Ptr GetDynamicObject(void) const;
|
||||
|
||||
DebugInfo GetDebugInfo(void) const;
|
||||
|
||||
static ConfigItem::Ptr GetObject(const String& type,
|
||||
|
@ -82,12 +80,9 @@ private:
|
|||
|
||||
ExpressionList::Ptr m_LinkedExpressionList;
|
||||
|
||||
DynamicObject::WeakPtr m_DynamicObject; /**< The instantiated version
|
||||
* of this configuration item */
|
||||
|
||||
static boost::mutex m_Mutex;
|
||||
|
||||
typedef std::map<std::pair<String, String>, ConfigItem::Ptr, pair_string_iless> ItemMap;
|
||||
typedef std::map<std::pair<String, String>, ConfigItem::Ptr> ItemMap;
|
||||
static ItemMap m_Items; /**< All registered configuration items. */
|
||||
|
||||
static ConfigItem::Ptr GetObjectUnlocked(const String& type,
|
||||
|
|
|
@ -192,7 +192,7 @@ void Expression::ExtractPath(const std::vector<String>& path, const ExpressionLi
|
|||
}
|
||||
}
|
||||
|
||||
void Expression::ExtractFiltered(const std::set<String, string_iless>& keys, const shared_ptr<ExpressionList>& result) const
|
||||
void Expression::ExtractFiltered(const std::set<String>& keys, const shared_ptr<ExpressionList>& result) const
|
||||
{
|
||||
if (keys.find(m_Key) != keys.end()) {
|
||||
result->AddExpression(*this);
|
||||
|
|
|
@ -62,7 +62,7 @@ public:
|
|||
void Execute(const Dictionary::Ptr& dictionary) const;
|
||||
|
||||
void ExtractPath(const std::vector<String>& path, const shared_ptr<ExpressionList>& result) const;
|
||||
void ExtractFiltered(const std::set<String, string_iless>& keys, const shared_ptr<ExpressionList>& result) const;
|
||||
void ExtractFiltered(const std::set<String>& keys, const shared_ptr<ExpressionList>& result) const;
|
||||
|
||||
void ErasePath(const std::vector<String>& path);
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ void ExpressionList::ExtractPath(const std::vector<String>& path, const Expressi
|
|||
}
|
||||
}
|
||||
|
||||
void ExpressionList::ExtractFiltered(const std::set<String, string_iless>& keys, const ExpressionList::Ptr& result) const
|
||||
void ExpressionList::ExtractFiltered(const std::set<String>& keys, const ExpressionList::Ptr& result) const
|
||||
{
|
||||
BOOST_FOREACH(const Expression& expression, m_Expressions) {
|
||||
expression.ExtractFiltered(keys, result);
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
size_t GetLength(void) const;
|
||||
|
||||
void ExtractPath(const std::vector<String>& path, const ExpressionList::Ptr& result) const;
|
||||
void ExtractFiltered(const std::set<String, string_iless>& keys, const ExpressionList::Ptr& result) const;
|
||||
void ExtractFiltered(const std::set<String>& keys, const ExpressionList::Ptr& result) const;
|
||||
|
||||
void ErasePath(const std::vector<String>& path);
|
||||
|
||||
|
|
|
@ -40,8 +40,8 @@ public:
|
|||
DECLARE_PTR_TYPEDEFS(DbType);
|
||||
|
||||
typedef boost::function<shared_ptr<DbObject> (const shared_ptr<DbType>&, const String&, const String&)> ObjectFactory;
|
||||
typedef std::map<String, DbType::Ptr, string_iless> TypeMap;
|
||||
typedef std::map<std::pair<String, String>, shared_ptr<DbObject>, pair_string_iless> ObjectMap;
|
||||
typedef std::map<String, DbType::Ptr> TypeMap;
|
||||
typedef std::map<std::pair<String, String>, shared_ptr<DbObject> > ObjectMap;
|
||||
|
||||
DbType(const String& name, const String& table, long tid, const String& idcolumn, const ObjectFactory& factory);
|
||||
|
||||
|
|
Loading…
Reference in New Issue