* @returns true if the value was retrieved, false otherwise.
*/
template<typename T>
- bool GetProperty(string key, T *value) const
+ bool GetProperty(const string& key, T *value) const
{
ConstDictionaryIterator i = m_Data.find(key);
* @param[out] value Pointer to the value.
* @returns true if the value was retrieved, false otherwise.
*/
- bool GetProperty(string key, Dictionary::Ptr *value)
+ bool GetProperty(const string& key, Dictionary::Ptr *value)
{
Object::Ptr object;
* @param value The value.
*/
template<typename T>
- void SetProperty(string key, const T& value)
+ void SetProperty(const string& key, const T& value)
{
pair<typename map<string, Variant>::iterator, bool> ret;
ret = m_Data.insert(make_pair(key, value));
return ctx.GetResult();
}
-vector<ConfigItem::Ptr> ConfigCompiler::CompileFile(string filename)
+vector<ConfigItem::Ptr> ConfigCompiler::CompileFile(const string& filename)
{
ifstream stream;
stream.open(filename, ifstream::in);
return CompileStream(&stream);
}
-vector<ConfigItem::Ptr> ConfigCompiler::CompileText(string text)
+vector<ConfigItem::Ptr> ConfigCompiler::CompileText(const string& text)
{
stringstream stream(text);
return CompileStream(&stream);
void Compile(void);
static vector<ConfigItem::Ptr> CompileStream(istream *stream);
- static vector<ConfigItem::Ptr> CompileFile(string filename);
- static vector<ConfigItem::Ptr> CompileText(string text);
+ static vector<ConfigItem::Ptr> CompileFile(const string& filename);
+ static vector<ConfigItem::Ptr> CompileText(const string& text);
void SetResult(vector<ConfigItem::Ptr> result);
vector<ConfigItem::Ptr> GetResult(void) const;
using namespace icinga;
-ConfigItem::ConfigItem(string type, string name, DebugInfo debuginfo)
+ConfigItem::ConfigItem(const string& type, const string& name, const DebugInfo& debuginfo)
: m_Type(type), m_Name(name), m_DebugInfo(debuginfo)
{
}
return m_Parents;
}
-void ConfigItem::AddParent(string parent)
+void ConfigItem::AddParent(const string& parent)
{
m_Parents.push_back(parent);
}
GetAllObjects()->RemoveObject(self);
}
-ConfigItem::Ptr ConfigItem::GetObject(string type, string name)
+ConfigItem::Ptr ConfigItem::GetObject(const string& type, const string& name)
{
ConfigItem::TNMap::Range range;
range = GetObjectsByTypeAndName()->GetRange(make_pair(type, name));
typedef ObjectMap<pair<string, string>, ConfigItem::Ptr> TNMap;
- ConfigItem(string type, string name, DebugInfo debuginfo);
+ ConfigItem(const string& type, const string& name, const DebugInfo& debuginfo);
string GetType(void) const;
string GetName(void) const;
vector<string> GetParents(void) const;
- void AddParent(string parent);
+ void AddParent(const string& parent);
ExpressionList::Ptr GetExpressionList(void) const;
void SetExpressionList(const ExpressionList::Ptr& exprl);
static ObjectSet<ConfigItem::Ptr>::Ptr GetAllObjects(void);
static TNMap::Ptr GetObjectsByTypeAndName(void);
- static ConfigItem::Ptr GetObject(string type, string name);
+ static ConfigItem::Ptr GetObject(const string& type, const string& name);
private:
string m_Type;
static bool GetTypeAndName(const ConfigItem::Ptr& object, pair<string, string> *key);
};
-
}
#endif /* CONFIGITEM_H */
using namespace icinga;
-Expression::Expression(string key, ExpressionOperator op, const Variant& value, const DebugInfo& debuginfo)
+Expression::Expression(const string& key, ExpressionOperator op, const Variant& value, const DebugInfo& debuginfo)
: m_Key(key), m_Operator(op), m_Value(value), m_DebugInfo(debuginfo)
{
}
void Expression::Execute(const Dictionary::Ptr& dictionary) const
{
Variant oldValue, newValue;
- dictionary->GetProperty(m_Key, &oldValue);
ExpressionList::Ptr exprl;
if (m_Value.GetType() == VariantObject)
case OperatorPlus:
if (exprl) {
+ dictionary->GetProperty(m_Key, &oldValue);
+
Dictionary::Ptr dict;
if (oldValue.GetType() == VariantObject)
dict = dynamic_pointer_cast<Dictionary>(oldValue.GetObject());
struct I2_DYN_API Expression
{
public:
- Expression(string key, ExpressionOperator op, const Variant& value, const DebugInfo& debuginfo);
+ Expression(const string& key, ExpressionOperator op, const Variant& value, const DebugInfo& debuginfo);
void Execute(const Dictionary::Ptr& dictionary) const;
return 1;
}
- for (int i = 0; i < 10000; i++) {
+ for (int i = 0; i < 1; i++) {
vector<ConfigItem::Ptr> objects = ConfigCompiler::CompileFile(string(argv[1]));
ConfigVM::ExecuteItems(objects);
}
- ObjectSet<DynamicObject::Ptr>::Iterator it;
+/* ObjectSet<DynamicObject::Ptr>::Iterator it;
for (it = DynamicObject::GetAllObjects()->Begin(); it != DynamicObject::GetAllObjects()->End(); it++) {
DynamicObject::Ptr obj = *it;
cout << "Object, name: " << obj->GetName() << ", type: " << obj->GetType() << endl;
MessagePart mp(obj->GetConfig());
cout << mp.ToJsonString() << endl;
}
-
+*/
return 0;
}