summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cpp/include/Ice/Object.h3
-rw-r--r--cpp/slice/Ice/Facet.ice28
-rw-r--r--cpp/src/Ice/Direct.cpp2
-rw-r--r--cpp/src/Ice/Incoming.cpp2
-rw-r--r--cpp/src/Ice/Object.cpp58
-rw-r--r--cpp/src/Ice/TraceUtil.cpp20
-rw-r--r--cpp/src/Ice/ice.dsp53
-rw-r--r--cpp/test/Ice/facets/AllTests.cpp10
-rw-r--r--cpp/test/Ice/facets/Collocated.cpp6
-rw-r--r--cpp/test/Ice/facets/Server.cpp6
-rw-r--r--cpp/test/Ice/facets/Test.ice5
-rw-r--r--cpp/test/Ice/facets/TestI.cpp11
-rw-r--r--cpp/test/Ice/facets/TestI.h8
13 files changed, 163 insertions, 49 deletions
diff --git a/cpp/include/Ice/Object.h b/cpp/include/Ice/Object.h
index e9eab76ae46..5536364fdb9 100644
--- a/cpp/include/Ice/Object.h
+++ b/cpp/include/Ice/Object.h
@@ -101,8 +101,7 @@ public:
void ice_addFacet(const ObjectPtr&, const ::std::string&);
void ice_removeFacet(const ::std::string&);
void ice_removeAllFacets();
- ObjectPtr ice_findFacet(const ::std::string&);
- ObjectPtr ice_findFacet(const ::std::vector< ::std::string>&, int = 0);
+ ObjectPtr ice_findFacet(const ::std::vector< ::std::string>&, int);
private:
diff --git a/cpp/slice/Ice/Facet.ice b/cpp/slice/Ice/Facet.ice
new file mode 100644
index 00000000000..636066d578c
--- /dev/null
+++ b/cpp/slice/Ice/Facet.ice
@@ -0,0 +1,28 @@
+// **********************************************************************
+//
+// Copyright (c) 2001
+// Mutable Realms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_FACET_ICE
+#define ICE_FACET_ICE
+
+#include <Ice/Identity.ice>
+
+module Ice
+{
+
+/**
+ *
+ * The facet path.
+ *
+ **/
+local sequence<string> FacetPath;
+
+};
+
+#endif
diff --git a/cpp/src/Ice/Direct.cpp b/cpp/src/Ice/Direct.cpp
index ae9bc3e7959..59d9ef67ff1 100644
--- a/cpp/src/Ice/Direct.cpp
+++ b/cpp/src/Ice/Direct.cpp
@@ -47,7 +47,7 @@ IceInternal::Direct::Direct(const ObjectAdapterPtr& adapter, const Current& curr
if(_servant && !_current.facet.empty())
{
- _facetServant = _servant->ice_findFacet(_current.facet);
+ _facetServant = _servant->ice_findFacet(_current.facet, 0);
if(!_facetServant)
{
FacetNotExistException ex(__FILE__, __LINE__);
diff --git a/cpp/src/Ice/Incoming.cpp b/cpp/src/Ice/Incoming.cpp
index 6b44306c703..4699e4b922f 100644
--- a/cpp/src/Ice/Incoming.cpp
+++ b/cpp/src/Ice/Incoming.cpp
@@ -100,7 +100,7 @@ IceInternal::Incoming::invoke(bool response)
{
if(!current.facet.empty())
{
- ObjectPtr facetServant = servant->ice_findFacet(current.facet);
+ ObjectPtr facetServant = servant->ice_findFacet(current.facet, 0);
if(!facetServant)
{
status = DispatchFacetNotExist;
diff --git a/cpp/src/Ice/Object.cpp b/cpp/src/Ice/Object.cpp
index 7bad13a59da..c64a503760a 100644
--- a/cpp/src/Ice/Object.cpp
+++ b/cpp/src/Ice/Object.cpp
@@ -343,37 +343,6 @@ Ice::Object::ice_removeAllFacets()
}
ObjectPtr
-Ice::Object::ice_findFacet(const string& name)
-{
- IceUtil::Mutex::Lock sync(_activeFacetMapMutex);
-
- map<string, ObjectPtr>::iterator p = _activeFacetMap.end();
-
- if(_activeFacetMapHint != _activeFacetMap.end())
- {
- if(_activeFacetMapHint->first == name)
- {
- p = _activeFacetMapHint;
- }
- }
-
- if(p == _activeFacetMap.end())
- {
- p = _activeFacetMap.find(name);
- }
-
- if(p != _activeFacetMap.end())
- {
- _activeFacetMapHint = p;
- return p->second;
- }
- else
- {
- return 0;
- }
-}
-
-ObjectPtr
Ice::Object::ice_findFacet(const vector<string>& path, int start)
{
int sz = path.size();
@@ -388,13 +357,32 @@ Ice::Object::ice_findFacet(const vector<string>& path, int start)
return this;
}
- ObjectPtr facet = ice_findFacet(path[start]);
- if(!facet)
{
- return 0;
+ IceUtil::Mutex::Lock sync(_activeFacetMapMutex);
+
+ map<string, ObjectPtr>::iterator p = _activeFacetMap.end();
+
+ if(_activeFacetMapHint != _activeFacetMap.end())
+ {
+ if(_activeFacetMapHint->first == path[start])
+ {
+ p = _activeFacetMapHint;
+ }
+ }
+
+ if(p == _activeFacetMap.end())
+ {
+ p = _activeFacetMap.find(path[start]);
+ }
+
+ if(p != _activeFacetMap.end())
+ {
+ _activeFacetMapHint = p;
+ return p->second->ice_findFacet(path, start + 1);
+ }
}
- return facet->ice_findFacet(path, start + 1);
+ return 0;
}
DispatchStatus
diff --git a/cpp/src/Ice/TraceUtil.cpp b/cpp/src/Ice/TraceUtil.cpp
index 8c30a38c821..98243178f3a 100644
--- a/cpp/src/Ice/TraceUtil.cpp
+++ b/cpp/src/Ice/TraceUtil.cpp
@@ -27,10 +27,10 @@ printHeader(ostream& s, BasicStream& stream)
{
Byte protVer;
stream.read(protVer);
- s << "\nprotocol version = " << static_cast<int>(protVer);
+// s << "\nprotocol version = " << static_cast<int>(protVer);
Byte encVer;
stream.read(encVer);
- s << "\nencoding version = " << static_cast<int>(encVer);
+// s << "\nencoding version = " << static_cast<int>(encVer);
Byte type;
stream.read(type);
s << "\nmessage type = " << static_cast<int>(type) << ' ';
@@ -93,9 +93,21 @@ printRequestHeader(ostream& s, BasicStream& stream)
Identity identity;
identity.__read(&stream);
s << "\nidentity = " << identity;
- string facet;
+ vector<string> facet;
stream.read(facet);
- s << "\nfacet = " << facet;
+ s << "\nfacet = ";
+ vector<string>::const_iterator p = facet.begin();
+ while(p != facet.end())
+ {
+ //
+ // TODO: Escape for whitespace and slashes.
+ //
+ s << *p++;
+ if(p != facet.end())
+ {
+ s << '/';
+ }
+ }
string operation;
stream.read(operation);
s << "\noperation = " << operation;
diff --git a/cpp/src/Ice/ice.dsp b/cpp/src/Ice/ice.dsp
index 24b90832f1a..7dbe9bf33df 100644
--- a/cpp/src/Ice/ice.dsp
+++ b/cpp/src/Ice/ice.dsp
@@ -176,6 +176,10 @@ SOURCE=.\Exception.cpp
# End Source File
# Begin Source File
+SOURCE=.\Facet.cpp
+# End Source File
+# Begin Source File
+
SOURCE=.\Identity.cpp
# End Source File
# Begin Source File
@@ -496,6 +500,10 @@ SOURCE=..\..\include\Ice\Ice.h
# End Source File
# Begin Source File
+SOURCE=..\..\include\Ice\Facet.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\include\Ice\Identity.h
# End Source File
# Begin Source File
@@ -988,6 +996,51 @@ BuildCmds= \
# End Source File
# Begin Source File
+SOURCE=..\..\slice\Ice\Facet.ice
+
+!IF "$(CFG)" == "Ice - Win32 Release"
+
+USERDEP__IDENT="../../bin/slice2cpp.exe"
+# Begin Custom Build
+InputPath=..\..\slice\Ice\Facet.ice
+
+BuildCmds= \
+ set PATH=%PATH%;..\..\lib \
+ ..\..\bin\slice2cpp.exe --dll-export ICE_API --include-dir Ice -I../../slice ../../slice/Ice/Facet.ice \
+ move Facet.h ..\..\include\Ice \
+
+
+"..\..\include\Ice\Facet.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"Facet.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "Ice - Win32 Debug"
+
+USERDEP__IDENT="../../bin/slice2cpp.exe"
+# Begin Custom Build
+InputPath=..\..\slice\Ice\Facet.ice
+
+BuildCmds= \
+ set PATH=%PATH%;..\..\lib \
+ ..\..\bin\slice2cpp.exe --dll-export ICE_API --include-dir Ice -I../../slice ../../slice/Ice/Facet.ice \
+ move Facet.h ..\..\include\Ice \
+
+
+"..\..\include\Ice\Facet.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"Facet.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
SOURCE=..\..\slice\Ice\Identity.ice
!IF "$(CFG)" == "Ice - Win32 Release"
diff --git a/cpp/test/Ice/facets/AllTests.cpp b/cpp/test/Ice/facets/AllTests.cpp
index 3937266c1d4..d208c308a33 100644
--- a/cpp/test/Ice/facets/AllTests.cpp
+++ b/cpp/test/Ice/facets/AllTests.cpp
@@ -52,11 +52,17 @@ allTests(const Ice::CommunicatorPtr& communicator)
test(ff->callF() == "F");
cout << "ok" << endl;
- cout << "testing facet G... " << flush;
- GPrx gf = GPrx::checkedCast(d, "facetG");
+ cout << "testing facet G, which is a sub-facet of E and F... " << flush;
+ GPrx gf = GPrx::checkedCast(ff, "facetGH");
test(gf);
test(gf->callG() == "G");
cout << "ok" << endl;
+ cout << "testing whether casting preserves the facet... " << flush;
+ HPrx hf = HPrx::checkedCast(gf);
+ test(hf);
+ test(hf->callH() == "H");
+ cout << "ok" << endl;
+
return gf;
}
diff --git a/cpp/test/Ice/facets/Collocated.cpp b/cpp/test/Ice/facets/Collocated.cpp
index b61182fada0..6257639d6b5 100644
--- a/cpp/test/Ice/facets/Collocated.cpp
+++ b/cpp/test/Ice/facets/Collocated.cpp
@@ -21,8 +21,10 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
Ice::ObjectPtr d = new DI;
adapter->add(d, Ice::stringToIdentity("d"));
d->ice_addFacet(d, "facetABCD");
- d->ice_addFacet(new FI, "facetEF");
- d->ice_addFacet(new GI(communicator), "facetG");
+ Ice::ObjectPtr f = new FI;
+ d->ice_addFacet(f, "facetEF");
+ Ice::ObjectPtr h = new HI(communicator);
+ f->ice_addFacet(h, "facetGH");
GPrx allTests(const Ice::CommunicatorPtr&);
allTests(communicator);
diff --git a/cpp/test/Ice/facets/Server.cpp b/cpp/test/Ice/facets/Server.cpp
index e78543578ea..7c25e743151 100644
--- a/cpp/test/Ice/facets/Server.cpp
+++ b/cpp/test/Ice/facets/Server.cpp
@@ -21,8 +21,10 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
Ice::ObjectPtr d = new DI;
adapter->add(d, Ice::stringToIdentity("d"));
d->ice_addFacet(d, "facetABCD");
- d->ice_addFacet(new FI, "facetEF");
- d->ice_addFacet(new GI(communicator), "facetG");
+ Ice::ObjectPtr f = new FI;
+ d->ice_addFacet(f, "facetEF");
+ Ice::ObjectPtr h = new HI(communicator);
+ f->ice_addFacet(h, "facetGH");
adapter->activate();
communicator->waitForShutdown();
diff --git a/cpp/test/Ice/facets/Test.ice b/cpp/test/Ice/facets/Test.ice
index 93e317a700a..22cd75c69d3 100644
--- a/cpp/test/Ice/facets/Test.ice
+++ b/cpp/test/Ice/facets/Test.ice
@@ -47,4 +47,9 @@ interface G
string callG();
};
+interface H extends G
+{
+ string callH();
+};
+
#endif
diff --git a/cpp/test/Ice/facets/TestI.cpp b/cpp/test/Ice/facets/TestI.cpp
index d3fdfe04379..19bdd0692d3 100644
--- a/cpp/test/Ice/facets/TestI.cpp
+++ b/cpp/test/Ice/facets/TestI.cpp
@@ -63,3 +63,14 @@ GI::callG(const Ice::Current&)
{
return "G";
}
+
+HI::HI(const Ice::CommunicatorPtr& communicator) :
+ GI(communicator)
+{
+}
+
+std::string
+HI::callH(const Ice::Current&)
+{
+ return "H";
+}
diff --git a/cpp/test/Ice/facets/TestI.h b/cpp/test/Ice/facets/TestI.h
index 5286eecd34a..0d089ee35ef 100644
--- a/cpp/test/Ice/facets/TestI.h
+++ b/cpp/test/Ice/facets/TestI.h
@@ -68,4 +68,12 @@ private:
Ice::CommunicatorPtr _communicator;
};
+class HI : virtual public H, virtual public GI
+{
+public:
+
+ HI(const Ice::CommunicatorPtr&);
+ virtual std::string callH(const Ice::Current&);
+};
+
#endif