summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <randomdan@riogrande.random.lan>2014-11-30 17:44:35 +0000
committerDan Goodliffe <randomdan@riogrande.random.lan>2014-11-30 17:44:35 +0000
commit15850cf44da3d14db0370b2144a294f42eb8345d (patch)
tree1c898d3eb57e7cfb6353b0b77262201603ed3ed0
parentOnly attempt to clear caches if the directory exists (diff)
downloadproject2-15850cf44da3d14db0370b2144a294f42eb8345d.tar.bz2
project2-15850cf44da3d14db0370b2144a294f42eb8345d.tar.xz
project2-15850cf44da3d14db0370b2144a294f42eb8345d.zip
Support returning/fetching a single item via ice
-rw-r--r--project2/ice/iceRows.cpp20
-rw-r--r--project2/ice/iceViewSerializer.cpp10
-rw-r--r--project2/ice/slice2Daemon.cpp4
-rw-r--r--project2/ice/slice2Rows.cpp2
-rw-r--r--project2/ice/unittests/expected/clientPresenter.log8
-rw-r--r--project2/ice/unittests/lib/testrows.xml6
-rw-r--r--project2/ice/unittests/testClient.cpp7
-rw-r--r--project2/ice/unittests/testClient.xml2
-rw-r--r--project2/ice/unittests/testDaemon.cpp6
-rw-r--r--project2/ice/unittests/unittest.ice2
-rw-r--r--project2/ice/unittests/views/UnitTest/SimpleInterface/SingleRow.xml5
11 files changed, 60 insertions, 12 deletions
diff --git a/project2/ice/iceRows.cpp b/project2/ice/iceRows.cpp
index 77519cd..be079dd 100644
--- a/project2/ice/iceRows.cpp
+++ b/project2/ice/iceRows.cpp
@@ -68,19 +68,25 @@ RowProcSerializer::Serialize(ModelPartPtr mp)
case mpt_Null:
return;
case mpt_Simple:
- case mpt_Complex:
case mpt_Dictionary:
throw std::runtime_error("Not a sequence of things");
+ case mpt_Complex:
+ {
+ IceRowState irs(mp);
+ irs.IterateOver(mp, rpc);
+ break;
+ }
case mpt_Sequence:
- IceRowState * irs = NULL;
- mp->OnEachChild(boost::bind(&RowProcSerializer::SerializeRow, this, boost::ref(irs), _2));
- if (irs) {
- delete irs;
+ {
+ IceRowState * irs = NULL;
+ mp->OnEachChild(boost::bind(&RowProcSerializer::SerializeRow, this, boost::ref(irs), _2));
+ if (irs) {
+ delete irs;
+ }
+ break;
}
- break;
}
}
-
}
void
diff --git a/project2/ice/iceViewSerializer.cpp b/project2/ice/iceViewSerializer.cpp
index b690224..7651fc1 100644
--- a/project2/ice/iceViewSerializer.cpp
+++ b/project2/ice/iceViewSerializer.cpp
@@ -50,10 +50,16 @@ IceViewSerializer::addNamedValue(const Glib::ustring & name, const VariableType
void
IceViewSerializer::addNewRow(const Glib::ustring & name) const
{
- rowmpp = mpp->GetChild(name);
- if (rowmpp) {
+ if (mpp->GetType() == Slicer::mpt_Complex) {
+ rowmpp = mpp;
rowmpp->Create();
}
+ else {
+ rowmpp = mpp->GetChild(name);
+ if (rowmpp) {
+ rowmpp->Create();
+ }
+ }
}
void
diff --git a/project2/ice/slice2Daemon.cpp b/project2/ice/slice2Daemon.cpp
index 3e66339..4cd879f 100644
--- a/project2/ice/slice2Daemon.cpp
+++ b/project2/ice/slice2Daemon.cpp
@@ -43,8 +43,8 @@ Slice2Daemon::visitOperation(const Slice::OperationPtr & o)
fprintf(code, "const ::Ice::Current &) {\n");
visitParameterMap(o);
if (o->returnType()) {
- fprintf(code, "\t\t\t\t%s rtn;\n", o->returnType()->typeId().c_str());
- fprintf(code, "\t\t\t\tSlicer::ModelPartPtr mpp = new Slicer::ModelPartForSequence< %s >(rtn);\n", o->returnType()->typeId().c_str());
+ fprintf(code, "\t\t\t\t%s rtn;\n", returnTypeToString(o->returnType(), o->returnIsOptional()).c_str());
+ fprintf(code, "\t\t\t\tSlicer::ModelPartPtr mpp = Slicer::ModelPartFor(rtn);\n");
fprintf(code, "\t\t\t\texecuteView(\"%s/%s/%s\", mpp, params);\n", module.c_str(), interface.c_str(), o->name().c_str());
fprintf(code, "\t\t\t\treturn rtn;\n");
}
diff --git a/project2/ice/slice2Rows.cpp b/project2/ice/slice2Rows.cpp
index 3534aff..cea2d6b 100644
--- a/project2/ice/slice2Rows.cpp
+++ b/project2/ice/slice2Rows.cpp
@@ -47,7 +47,7 @@ Slice2Rows::visitOperation(const Slice::OperationPtr & o)
fprintf(code, "\t\t\t\t\t\tauto result = ");
CallOperation(o);
fprintf(code, ";\n");
- fprintf(code, "\t\t\t\t\t\tSlicer::ModelPartPtr mp = new Slicer::ModelPartForSequence<decltype(result)>(&result);\n");
+ fprintf(code, "\t\t\t\t\t\tSlicer::ModelPartPtr mp = Slicer::ModelPartFor(result);\n");
fprintf(code, "\t\t\t\t\t\ttoRpc->Serialize(mp);\n");
fprintf(code, "\t\t\t\t\t}\n\n");
ParameterVariables(o);
diff --git a/project2/ice/unittests/expected/clientPresenter.log b/project2/ice/unittests/expected/clientPresenter.log
index cda61fc..cebd0bf 100644
--- a/project2/ice/unittests/expected/clientPresenter.log
+++ b/project2/ice/unittests/expected/clientPresenter.log
@@ -1,4 +1,12 @@
init
+addNewRowSet: row
+addNewArray: rec(1)
+addNewRow: rec
+addNamedValue: a=3
+addNamedValue: b=single
+finishRow
+finishArray: (1)
+finishRowSet
addNewRowSet: somerows
addNewArray: rec(1)
addNewRow: rec
diff --git a/project2/ice/unittests/lib/testrows.xml b/project2/ice/unittests/lib/testrows.xml
index 876e311..75578d6 100644
--- a/project2/ice/unittests/lib/testrows.xml
+++ b/project2/ice/unittests/lib/testrows.xml
@@ -2,6 +2,12 @@
<p2:xpathrows xmlns:p2="http://project2.randomdan.homeip.net" name="filelist">
<url><root source="config" name="dataroot"/>/unittest-data.xml</url>
<filterviews>
+ <single root="/root/record[3]">
+ <fields>
+ <a xpath="a"/>
+ <b xpath="b"/>
+ </fields>
+ </single>
<default root="/root/record">
<fields>
<a xpath="a"/>
diff --git a/project2/ice/unittests/testClient.cpp b/project2/ice/unittests/testClient.cpp
index e5d45b7..4040b60 100644
--- a/project2/ice/unittests/testClient.cpp
+++ b/project2/ice/unittests/testClient.cpp
@@ -24,6 +24,11 @@ class Dummy : public UnitTest::SimpleInterface {
{
}
+ UnitTest::SimplePtr SingleRow(const Ice::Current&)
+ {
+ return new UnitTest::Simple { 3, "single" };
+ }
+
UnitTest::Simples SomeRows(const Ice::Current&)
{
UnitTest::Simples rtn {
@@ -66,6 +71,7 @@ commonTests()
BOOST_TEST_CHECKPOINT("Verify loaded");
BOOST_REQUIRE(ElementLoader::getFor("UnitTest-SimpleInterface-SomeTask"));
BOOST_REQUIRE(ElementLoader::getFor("UnitTest-SimpleInterface-SomeTaskParams"));
+ BOOST_REQUIRE(ElementLoader::getFor("UnitTest-SimpleInterface-SingleRow"));
BOOST_REQUIRE(ElementLoader::getFor("UnitTest-SimpleInterface-SomeRows"));
BOOST_REQUIRE(ElementLoader::getFor("UnitTest-SimpleInterface-SomeRowsParams"));
@@ -96,6 +102,7 @@ unloadTests()
BOOST_TEST_CHECKPOINT("Verify unloaded");
BOOST_REQUIRE_THROW(ElementLoader::getFor("UnitTest-SimpleInterface-SomeTask"), NotSupported);
BOOST_REQUIRE_THROW(ElementLoader::getFor("UnitTest-SimpleInterface-SomeTaskParams"), NotSupported);
+ BOOST_REQUIRE_THROW(ElementLoader::getFor("UnitTest-SimpleInterface-SingleRow"), NotSupported);
BOOST_REQUIRE_THROW(ElementLoader::getFor("UnitTest-SimpleInterface-SomeRows"), NotSupported);
BOOST_REQUIRE_THROW(ElementLoader::getFor("UnitTest-SimpleInterface-SomeRowsParams"), NotSupported);
}
diff --git a/project2/ice/unittests/testClient.xml b/project2/ice/unittests/testClient.xml
index 4ae33b1..c8fb208 100644
--- a/project2/ice/unittests/testClient.xml
+++ b/project2/ice/unittests/testClient.xml
@@ -3,8 +3,10 @@
xmlns:p2="http://project2.randomdan.homeip.net">
<p2:UnitTest-SimpleInterface-SomeTask datasource="unittest-ice-datasource" objectId="testObject" />
<p2:UnitTest-SimpleInterface-SomeTaskParams datasource="unittest-ice-datasource" objectId="testObject" a="1" b="first" />
+ <p2:UnitTest-SimpleInterface-SingleRow name="row" datasource="unittest-ice-datasource" objectId="testObject" />
<p2:UnitTest-SimpleInterface-SomeRows name="rows" datasource="unittest-ice-datasource" objectId="testObject" />
<p2:UnitTest-SimpleInterface-SomeRowsParams name="rowsParams" datasource="unittest-ice-datasource" objectId="testObject" a="2" b="second" />
+ <p2:view source="row" recordname="rec" rootname="row" />
<p2:view source="rows" recordname="rec" rootname="somerows" />
<p2:view source="rowsParams" recordname="rec" rootname="somerowsparams" />
</test>
diff --git a/project2/ice/unittests/testDaemon.cpp b/project2/ice/unittests/testDaemon.cpp
index 9e86a03..fe0b0f5 100644
--- a/project2/ice/unittests/testDaemon.cpp
+++ b/project2/ice/unittests/testDaemon.cpp
@@ -74,6 +74,12 @@ commonTests()
BOOST_REQUIRE(si);
si->ice_ping();
+ BOOST_TEST_CHECKPOINT("Call view (single)");
+ auto single = si->SingleRow();
+ BOOST_REQUIRE(single);
+ BOOST_REQUIRE_EQUAL(1, single->a);
+ BOOST_REQUIRE_EQUAL("third", single->b);
+
BOOST_TEST_CHECKPOINT("Call view (no parameters)");
auto rows = si->SomeRows();
BOOST_REQUIRE_EQUAL(4, rows.size());
diff --git a/project2/ice/unittests/unittest.ice b/project2/ice/unittests/unittest.ice
index 60e44bb..f7305d3 100644
--- a/project2/ice/unittests/unittest.ice
+++ b/project2/ice/unittests/unittest.ice
@@ -10,6 +10,8 @@ module UnitTest {
interface SimpleInterface
{
["project2:rows"]
+ Simple SingleRow();
+ ["project2:rows"]
Simples SomeRows();
["project2:rows"]
Simples SomeRowsParams(int a, string b);
diff --git a/project2/ice/unittests/views/UnitTest/SimpleInterface/SingleRow.xml b/project2/ice/unittests/views/UnitTest/SimpleInterface/SingleRow.xml
new file mode 100644
index 0000000..2b54b96
--- /dev/null
+++ b/project2/ice/unittests/views/UnitTest/SimpleInterface/SingleRow.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0"?>
+<block xmlns:p2="http://project2.randomdan.homeip.net" xmlns:xi="http://www.w3.org/2001/XInclude">
+ <xi:include href="../../../lib/testrows.xml"/>
+ <p2:flatview source="filelist" recordname="element" filter="single"/>
+</block>