summaryrefslogtreecommitdiff
path: root/server/src/artefact.cc
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/artefact.cc')
-rw-r--r--server/src/artefact.cc59
1 files changed, 45 insertions, 14 deletions
diff --git a/server/src/artefact.cc b/server/src/artefact.cc
index 24114f9..f3e739d 100644
--- a/server/src/artefact.cc
+++ b/server/src/artefact.cc
@@ -34,10 +34,10 @@
Artefact::Artefact()
{
-#ifndef WITHOUT_PENTOMINOS
+#ifndef WITHOUT_ARTEFACT
+
PRACRO_DEBUG(artefact, "Creating artefact connection %s : %d\n",
Conf::artefact_addr.c_str(), Conf::artefact_port);
-#endif/*WITHOUT_PENTOMINOS*/
atfh = atf_init();
if(!atfh) PRACRO_ERR(artefact, "Out of memory!\n");
@@ -46,19 +46,26 @@ Artefact::Artefact()
Conf::artefact_addr.c_str(),
Conf::artefact_port,
Conf::artefact_use_ssl);
+
+#endif/*WITHOUT_ARTEFACT*/
}
Artefact::~Artefact()
{
+#ifndef WITHOUT_ARTEFACT
+
atf_disconnect(conn);
atf_close(atfh);
+
+#endif/*WITHOUT_ARTEFACT*/
}
+#ifndef WITHOUT_ARTEFACT
static QueryResult node2result(atf_result_node_t *node, time_t timestamp)
{
QueryResult rnode;
rnode.timestamp = timestamp;
- rnode.source = "pentominos";
+ rnode.source = "artefact";
if(!node) return rnode;
@@ -74,11 +81,18 @@ static QueryResult node2result(atf_result_node_t *node, time_t timestamp)
return rnode;
}
+#endif/*WITHOUT_ARTEFACT*/
QueryResult Artefact::exec(Query &query,
std::string patientid,
std::string user)
{
+ QueryResult rroot;
+ rroot.timestamp = 0;
+ rroot.source = "pentominos";
+
+#ifndef WITHOUT_ARTEFACT
+
atf_transaction_t* atft = NULL;
atf_reply_t *reply = NULL;
atf_result_t *result = NULL;
@@ -87,10 +101,6 @@ QueryResult Artefact::exec(Query &query,
time_t timestamp;
atf_id id;
- QueryResult rroot;
- rroot.timestamp = 0;
- rroot.source = "pentominos";
-
if(query.attributes.find("class") == query.attributes.end()) {
PRACRO_ERR(artefact, "Missing 'class' attribute!\n");
goto aaarg;
@@ -135,22 +145,43 @@ QueryResult Artefact::exec(Query &query,
if(reply) atf_free_reply(reply);
if(atft) atf_free_transaction(atft);
+#endif/*WITHOUT_ARTEFACT*/
+
return rroot;
}
#ifdef TEST_ARTEFACT
-//Additional dependency files
-//deps:
-//Required cflags (autoconf vars may be used)
-//cflags:
-//Required link options (autoconf vars may be used)
-//libs:
+//deps: configuration.cc debug.cc
+//cflags: $(ATF_CFLAGS) -I..
+//libs: $(ATF_LIBS)
#include "test.h"
TEST_BEGIN;
-// TODO: Put some testcode here (see test.h for usable macros).
+pracro_debug_init();
+pracro_debug_parse("+all");
+
+{
+ Artefact atf;
+ Query q;
+ q.attributes["class"] = "echo";
+ QueryResult res = atf.exec(q, "1505050505", "me");
+
+ res.print();
+}
+
+{
+ Conf::artefact_addr = "nowhere_at_all.com";
+ Conf::artefact_port = 10000;
+
+ Artefact atf;
+ Query q;
+ q.attributes["class"] = "echo";
+ QueryResult res = atf.exec(q, "1505050505", "me");
+
+ res.print();
+}
TEST_END;