diff --git a/lib/config/configitem.cpp b/lib/config/configitem.cpp index 81f699ecc..c3b87f857 100644 --- a/lib/config/configitem.cpp +++ b/lib/config/configitem.cpp @@ -35,6 +35,7 @@ #include "base/serializer.hpp" #include "base/json.hpp" #include "base/exception.hpp" +#include "base/scriptfunction.hpp" #include #include #include @@ -46,6 +47,8 @@ ConfigItem::TypeMap ConfigItem::m_Items; ConfigItem::ItemList ConfigItem::m_UnnamedItems; ConfigItem::ItemList ConfigItem::m_CommittedItems; +REGISTER_SCRIPTFUNCTION(__commit, &ConfigItem::ScriptCommit); + /** * Constructor for the ConfigItem class. * @@ -392,6 +395,29 @@ bool ConfigItem::ActivateItems(void) return true; } +bool ConfigItem::ScriptCommit(void) +{ + WorkQueue upq(25000, Application::GetConcurrency()); + + if (!CommitNewItems(upq)) + return false; + + BOOST_FOREACH(const DynamicType::Ptr& type, DynamicType::GetTypes()) { + BOOST_FOREACH(const DynamicObject::Ptr& object, type->GetObjects()) { + if (object->IsActive()) + continue; + +#ifdef I2_DEBUG + Log(LogDebug, "ConfigItem") + << "Activating object '" << object->GetName() << "' of type '" << object->GetType()->GetName() << "'"; +#endif /* I2_DEBUG */ + upq.Enqueue(boost::bind(&DynamicObject::Activate, object)); + } + } + + return true; +} + std::vector ConfigItem::GetItems(const String& type) { std::vector items; diff --git a/lib/config/configitem.hpp b/lib/config/configitem.hpp index a31def4f6..af383877c 100644 --- a/lib/config/configitem.hpp +++ b/lib/config/configitem.hpp @@ -67,6 +67,8 @@ public: static bool CommitItems(void); static bool ActivateItems(void); + static bool ScriptCommit(void); + static std::vector GetItems(const String& type); private: