**=========================================================================
*/
-Object::Object(const gnucomo_database &db) : database_entity(db, "object")
+Object::Object(gnucomo_database &gdb) : database_entity(gdb, "object")
{
+ id = "0";
+ hostname = "";
}
+Object::Object(gnucomo_database &gdb, String name) : database_entity(gdb, "object")
+{
+ id = "0";
+ hostname = name;
+
+ String objectid("");
+ String check_host;
+
+ check_host += "objectname = '";
+ check_host += hostname;
+ check_host += "'";
+
+ if (find_one(check_host) > 0)
+ {
+ id = fields["objectid"];
+ std::cerr << "Object id = " << id << "\n";
+ }
+
+}
+
+std::list<ObjectLog> Object::select_logs(UTC start, UTC finish, String service)
+{
+
+ int rows_found;
+ std::list<ObjectLog> logs;
+
+ String where("objectid=");
+
+ where += id;
+ where += " and timestamp >= '";
+ where += start.format();
+ where += "' and timestamp <= '";
+ where += finish.format();
+ where += "' and servicecode = '";
+ where += service;
+ where += "'";
+
+ rows_found = find_many("log", where);
+
+ for (int r = 0; r < rows_found; r++)
+ {
+ ObjectLog ol(this, r);
+ logs.push_back(ol);
+ }
+
+ return logs;
+}