diff options
author | Matthew Newhook <matthew@zeroc.com> | 2001-12-17 17:39:57 +0000 |
---|---|---|
committer | Matthew Newhook <matthew@zeroc.com> | 2001-12-17 17:39:57 +0000 |
commit | e3193577c75807674546ca3982a688b6d02c7c00 (patch) | |
tree | 8f39fad8b34baa82ccef24955b0d2225b8a34e1f /cpp/src | |
parent | fixes (diff) | |
download | ice-e3193577c75807674546ca3982a688b6d02c7c00.tar.bz2 ice-e3193577c75807674546ca3982a688b6d02c7c00.tar.xz ice-e3193577c75807674546ca3982a688b6d02c7c00.zip |
First cut at full IceStorm federation.
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/IceStorm/.depend | 11 | ||||
-rw-r--r-- | cpp/src/IceStorm/Admin.cpp | 19 | ||||
-rw-r--r-- | cpp/src/IceStorm/Grammar.y | 17 | ||||
-rw-r--r-- | cpp/src/IceStorm/LinkDB.ice (renamed from cpp/src/IceStorm/LinkInfo.ice) | 6 | ||||
-rw-r--r-- | cpp/src/IceStorm/LinkSubscriber.cpp | 2 | ||||
-rw-r--r-- | cpp/src/IceStorm/Makefile | 19 | ||||
-rw-r--r-- | cpp/src/IceStorm/Parser.cpp | 222 | ||||
-rw-r--r-- | cpp/src/IceStorm/Parser.h | 14 | ||||
-rw-r--r-- | cpp/src/IceStorm/Scanner.l | 8 | ||||
-rw-r--r-- | cpp/src/IceStorm/TopicI.cpp | 42 | ||||
-rw-r--r-- | cpp/src/IceStorm/TopicI.h | 1 | ||||
-rw-r--r-- | cpp/src/IceStorm/WeightedGraph.cpp | 426 | ||||
-rw-r--r-- | cpp/src/IceStorm/WeightedGraph.h | 115 | ||||
-rw-r--r-- | cpp/src/IceStorm/graph-sample.xml | 13 |
14 files changed, 868 insertions, 47 deletions
diff --git a/cpp/src/IceStorm/.depend b/cpp/src/IceStorm/.depend index 40178d5aa28..2bd8d34a25c 100644 --- a/cpp/src/IceStorm/.depend +++ b/cpp/src/IceStorm/.depend @@ -6,14 +6,15 @@ OnewaySubscriber.o: OnewaySubscriber.cpp ../../include/Ice/Ice.h ../../include/I OnewayBatchSubscriber.o: OnewayBatchSubscriber.cpp ../../include/Ice/Ice.h ../../include/Ice/Initialize.h ../../include/Ice/CommunicatorF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalException.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/PropertiesF.h ../../include/Ice/InstanceF.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/Stream.h ../../include/Ice/Communicator.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/UserExceptionFactoryF.h ../../include/Ice/StreamF.h ../../include/Ice/ObjectFactory.h ../../include/Ice/UserExceptionFactory.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/Identity.h ../../include/Ice/ServantLocator.h ../../include/Ice/Current.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/IdentityUtil.h ../IceStorm/OnewayBatchSubscriber.h ../IceStorm/OnewaySubscriber.h ../IceStorm/Subscriber.h ../IceStorm/Flushable.h ../IceStorm/TraceLevels.h ../IceStorm/Flusher.h LinkSubscriber.o: LinkSubscriber.cpp ../IceStorm/LinkSubscriber.h ../IceStorm/Flushable.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/IceUtil/Shared.h ../IceStorm/Subscriber.h ../../include/Ice/Current.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalException.h ../../include/Ice/LocalObject.h ../../include/Ice/Identity.h ../IceStorm/IceStormInternal.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/Ice/BasicStream.h ../../include/Ice/InstanceF.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../../include/Ice/Direct.h ../../include/Ice/ServantLocatorF.h ../../include/IceStorm/IceStorm.h ../IceStorm/TraceLevels.h ../../include/Ice/PropertiesF.h ../../include/Ice/LoggerF.h ../../include/Ice/Ice.h ../../include/Ice/Initialize.h ../../include/Ice/CommunicatorF.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/Stream.h ../../include/Ice/Communicator.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/UserExceptionFactoryF.h ../../include/Ice/StreamF.h ../../include/Ice/ObjectFactory.h ../../include/Ice/UserExceptionFactory.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/ServantLocator.h ../../include/Ice/IdentityUtil.h SubscriberFactory.o: SubscriberFactory.cpp ../../include/Ice/Ice.h ../../include/Ice/Initialize.h ../../include/Ice/CommunicatorF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalException.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/PropertiesF.h ../../include/Ice/InstanceF.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/Stream.h ../../include/Ice/Communicator.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/UserExceptionFactoryF.h ../../include/Ice/StreamF.h ../../include/Ice/ObjectFactory.h ../../include/Ice/UserExceptionFactory.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/Identity.h ../../include/Ice/ServantLocator.h ../../include/Ice/Current.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/IdentityUtil.h ../IceStorm/SubscriberFactory.h ../IceStorm/IceStormInternal.h ../../include/Ice/Outgoing.h ../../include/Ice/BasicStream.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../../include/Ice/Direct.h ../../include/IceStorm/IceStorm.h ../IceStorm/LinkSubscriber.h ../IceStorm/Flushable.h ../IceStorm/Subscriber.h ../IceStorm/OnewaySubscriber.h ../IceStorm/OnewayBatchSubscriber.h ../IceStorm/Flusher.h ../IceStorm/TraceLevels.h -TopicI.o: TopicI.cpp ../../include/Ice/Ice.h ../../include/Ice/Initialize.h ../../include/Ice/CommunicatorF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalException.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/PropertiesF.h ../../include/Ice/InstanceF.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/Stream.h ../../include/Ice/Communicator.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/UserExceptionFactoryF.h ../../include/Ice/StreamF.h ../../include/Ice/ObjectFactory.h ../../include/Ice/UserExceptionFactory.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/Identity.h ../../include/Ice/ServantLocator.h ../../include/Ice/Current.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/IdentityUtil.h ../../include/Ice/Functional.h ../../include/IceUtil/Functional.h ../IceStorm/TopicI.h ../IceStorm/IceStormInternal.h ../../include/Ice/Outgoing.h ../../include/Ice/BasicStream.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../../include/Ice/Direct.h ../../include/IceStorm/IceStorm.h ../IceStorm/IdentityLinkDict.h ../../include/Freeze/Map.h ../../include/Freeze/DB.h ../../include/Freeze/DBException.h ../../include/Freeze/DBF.h ../../include/Freeze/EvictorF.h ../IceStorm/LinkInfo.h ../IceStorm/SubscriberFactory.h ../IceStorm/Subscriber.h ../IceStorm/TraceLevels.h -TopicManagerI.o: TopicManagerI.cpp ../../include/Ice/Ice.h ../../include/Ice/Initialize.h ../../include/Ice/CommunicatorF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalException.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/PropertiesF.h ../../include/Ice/InstanceF.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/Stream.h ../../include/Ice/Communicator.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/UserExceptionFactoryF.h ../../include/Ice/StreamF.h ../../include/Ice/ObjectFactory.h ../../include/Ice/UserExceptionFactory.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/Identity.h ../../include/Ice/ServantLocator.h ../../include/Ice/Current.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/IdentityUtil.h ../IceStorm/TopicManagerI.h ../../include/IceStorm/IceStorm.h ../../include/Ice/Outgoing.h ../../include/Ice/BasicStream.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../../include/Ice/Direct.h ../IceStorm/StringBoolDict.h ../../include/Freeze/Map.h ../../include/Freeze/DB.h ../../include/Freeze/DBException.h ../../include/Freeze/DBF.h ../../include/Freeze/EvictorF.h ../IceStorm/TopicI.h ../IceStorm/IceStormInternal.h ../IceStorm/IdentityLinkDict.h ../IceStorm/LinkInfo.h ../IceStorm/SubscriberFactory.h ../IceStorm/Flusher.h ../IceStorm/TraceLevels.h +TopicI.o: TopicI.cpp ../../include/Ice/Ice.h ../../include/Ice/Initialize.h ../../include/Ice/CommunicatorF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalException.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/PropertiesF.h ../../include/Ice/InstanceF.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/Stream.h ../../include/Ice/Communicator.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/UserExceptionFactoryF.h ../../include/Ice/StreamF.h ../../include/Ice/ObjectFactory.h ../../include/Ice/UserExceptionFactory.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/Identity.h ../../include/Ice/ServantLocator.h ../../include/Ice/Current.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/IdentityUtil.h ../../include/Ice/Functional.h ../../include/IceUtil/Functional.h ../IceStorm/TopicI.h ../IceStorm/IceStormInternal.h ../../include/Ice/Outgoing.h ../../include/Ice/BasicStream.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../../include/Ice/Direct.h ../../include/IceStorm/IceStorm.h ../IceStorm/IdentityLinkDict.h ../../include/Freeze/Map.h ../../include/Freeze/DB.h ../../include/Freeze/DBException.h ../../include/Freeze/DBF.h ../../include/Freeze/EvictorF.h ../IceStorm/LinkDB.h ../IceStorm/SubscriberFactory.h ../IceStorm/Subscriber.h ../IceStorm/TraceLevels.h +TopicManagerI.o: TopicManagerI.cpp ../../include/Ice/Ice.h ../../include/Ice/Initialize.h ../../include/Ice/CommunicatorF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalException.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/PropertiesF.h ../../include/Ice/InstanceF.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/Stream.h ../../include/Ice/Communicator.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/UserExceptionFactoryF.h ../../include/Ice/StreamF.h ../../include/Ice/ObjectFactory.h ../../include/Ice/UserExceptionFactory.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/Identity.h ../../include/Ice/ServantLocator.h ../../include/Ice/Current.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/IdentityUtil.h ../IceStorm/TopicManagerI.h ../../include/IceStorm/IceStorm.h ../../include/Ice/Outgoing.h ../../include/Ice/BasicStream.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../../include/Ice/Direct.h ../IceStorm/StringBoolDict.h ../../include/Freeze/Map.h ../../include/Freeze/DB.h ../../include/Freeze/DBException.h ../../include/Freeze/DBF.h ../../include/Freeze/EvictorF.h ../IceStorm/TopicI.h ../IceStorm/IceStormInternal.h ../IceStorm/IdentityLinkDict.h ../IceStorm/LinkDB.h ../IceStorm/SubscriberFactory.h ../IceStorm/Flusher.h ../IceStorm/TraceLevels.h StringBoolDict.o: StringBoolDict.cpp ../../include/Ice/BasicStream.h ../../include/Ice/InstanceF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Buffer.h ../IceStorm/StringBoolDict.h ../../include/Freeze/Map.h ../../include/Freeze/DB.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalException.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/CommunicatorF.h ../../include/Freeze/DBException.h ../../include/Freeze/DBF.h ../../include/Freeze/EvictorF.h ../../include/Ice/Ice.h ../../include/Ice/Initialize.h ../../include/Ice/PropertiesF.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/Stream.h ../../include/Ice/Communicator.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/UserExceptionFactoryF.h ../../include/Ice/StreamF.h ../../include/Ice/ObjectFactory.h ../../include/Ice/UserExceptionFactory.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/Identity.h ../../include/Ice/ServantLocator.h ../../include/Ice/Current.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/IdentityUtil.h -IdentityLinkDict.o: IdentityLinkDict.cpp ../../include/Ice/BasicStream.h ../../include/Ice/InstanceF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Buffer.h ../IceStorm/IdentityLinkDict.h ../../include/Freeze/Map.h ../../include/Freeze/DB.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalException.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/CommunicatorF.h ../../include/Freeze/DBException.h ../../include/Freeze/DBF.h ../../include/Freeze/EvictorF.h ../../include/Ice/Ice.h ../../include/Ice/Initialize.h ../../include/Ice/PropertiesF.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/Stream.h ../../include/Ice/Communicator.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/UserExceptionFactoryF.h ../../include/Ice/StreamF.h ../../include/Ice/ObjectFactory.h ../../include/Ice/UserExceptionFactory.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/Identity.h ../../include/Ice/ServantLocator.h ../../include/Ice/Current.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/IdentityUtil.h ../IceStorm/LinkInfo.h ../../include/Ice/Outgoing.h ../../include/Ice/Incoming.h ../../include/Ice/Direct.h ../IceStorm/IceStormInternal.h ../../include/IceStorm/IceStorm.h -LinkInfo.o: LinkInfo.cpp ../IceStorm/LinkInfo.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalException.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Current.h ../../include/Ice/Identity.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/Ice/BasicStream.h ../../include/Ice/InstanceF.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../../include/Ice/Direct.h ../../include/Ice/ServantLocatorF.h ../IceStorm/IceStormInternal.h ../../include/IceStorm/IceStorm.h +IdentityLinkDict.o: IdentityLinkDict.cpp ../../include/Ice/BasicStream.h ../../include/Ice/InstanceF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Buffer.h ../IceStorm/IdentityLinkDict.h ../../include/Freeze/Map.h ../../include/Freeze/DB.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalException.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/CommunicatorF.h ../../include/Freeze/DBException.h ../../include/Freeze/DBF.h ../../include/Freeze/EvictorF.h ../../include/Ice/Ice.h ../../include/Ice/Initialize.h ../../include/Ice/PropertiesF.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/Stream.h ../../include/Ice/Communicator.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/UserExceptionFactoryF.h ../../include/Ice/StreamF.h ../../include/Ice/ObjectFactory.h ../../include/Ice/UserExceptionFactory.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/Identity.h ../../include/Ice/ServantLocator.h ../../include/Ice/Current.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/IdentityUtil.h ../IceStorm/LinkDB.h ../../include/Ice/Outgoing.h ../../include/Ice/Incoming.h ../../include/Ice/Direct.h ../IceStorm/IceStormInternal.h ../../include/IceStorm/IceStorm.h +LinkDB.o: LinkDB.cpp ../IceStorm/LinkDB.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalException.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Current.h ../../include/Ice/Identity.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/Ice/BasicStream.h ../../include/Ice/InstanceF.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../../include/Ice/Direct.h ../../include/Ice/ServantLocatorF.h ../IceStorm/IceStormInternal.h ../../include/IceStorm/IceStorm.h IceStormInternal.o: IceStormInternal.cpp ../IceStorm/IceStormInternal.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalException.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Current.h ../../include/Ice/Identity.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/Ice/BasicStream.h ../../include/Ice/InstanceF.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../../include/Ice/Direct.h ../../include/Ice/ServantLocatorF.h ../../include/IceStorm/IceStorm.h Server.o: Server.cpp ../../include/Freeze/Application.h ../../include/Ice/Application.h ../../include/Ice/Ice.h ../../include/Ice/Initialize.h ../../include/Ice/CommunicatorF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalException.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/PropertiesF.h ../../include/Ice/InstanceF.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/Stream.h ../../include/Ice/Communicator.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/UserExceptionFactoryF.h ../../include/Ice/StreamF.h ../../include/Ice/ObjectFactory.h ../../include/Ice/UserExceptionFactory.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/Identity.h ../../include/Ice/ServantLocator.h ../../include/Ice/Current.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/IdentityUtil.h ../../include/Freeze/Freeze.h ../../include/Freeze/Initialize.h ../../include/Freeze/DBF.h ../../include/Freeze/DB.h ../../include/Freeze/DBException.h ../../include/Freeze/EvictorF.h ../../include/Freeze/Evictor.h ../../include/Freeze/Map.h ../IceStorm/TopicManagerI.h ../../include/IceStorm/IceStorm.h ../../include/Ice/Outgoing.h ../../include/Ice/BasicStream.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../../include/Ice/Direct.h ../IceStorm/StringBoolDict.h ../IceStorm/TraceLevels.h Admin.o: Admin.cpp ../../include/Ice/Application.h ../../include/Ice/Ice.h ../../include/Ice/Initialize.h ../../include/Ice/CommunicatorF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalException.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/PropertiesF.h ../../include/Ice/InstanceF.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/Stream.h ../../include/Ice/Communicator.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/UserExceptionFactoryF.h ../../include/Ice/StreamF.h ../../include/Ice/ObjectFactory.h ../../include/Ice/UserExceptionFactory.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/Identity.h ../../include/Ice/ServantLocator.h ../../include/Ice/Current.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/IdentityUtil.h ../IceStorm/Parser.h ../../include/IceStorm/IceStorm.h ../../include/Ice/Outgoing.h ../../include/Ice/BasicStream.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../../include/Ice/Direct.h Grammar.o: Grammar.cpp ../../include/Ice/Ice.h ../../include/Ice/Initialize.h ../../include/Ice/CommunicatorF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalException.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/PropertiesF.h ../../include/Ice/InstanceF.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/Stream.h ../../include/Ice/Communicator.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/UserExceptionFactoryF.h ../../include/Ice/StreamF.h ../../include/Ice/ObjectFactory.h ../../include/Ice/UserExceptionFactory.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/Identity.h ../../include/Ice/ServantLocator.h ../../include/Ice/Current.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/IdentityUtil.h ../IceStorm/Parser.h ../../include/IceStorm/IceStorm.h ../../include/Ice/Outgoing.h ../../include/Ice/BasicStream.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../../include/Ice/Direct.h Scanner.o: Scanner.cpp ../../include/Ice/Ice.h ../../include/Ice/Initialize.h ../../include/Ice/CommunicatorF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalException.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/PropertiesF.h ../../include/Ice/InstanceF.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/Stream.h ../../include/Ice/Communicator.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/UserExceptionFactoryF.h ../../include/Ice/StreamF.h ../../include/Ice/ObjectFactory.h ../../include/Ice/UserExceptionFactory.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/Identity.h ../../include/Ice/ServantLocator.h ../../include/Ice/Current.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/IdentityUtil.h ../IceStorm/Parser.h ../../include/IceStorm/IceStorm.h ../../include/Ice/Outgoing.h ../../include/Ice/BasicStream.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../../include/Ice/Direct.h ../IceStorm/Grammar.h -Parser.o: Parser.cpp ../../include/Ice/Ice.h ../../include/Ice/Initialize.h ../../include/Ice/CommunicatorF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalException.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/PropertiesF.h ../../include/Ice/InstanceF.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/Stream.h ../../include/Ice/Communicator.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/UserExceptionFactoryF.h ../../include/Ice/StreamF.h ../../include/Ice/ObjectFactory.h ../../include/Ice/UserExceptionFactory.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/Identity.h ../../include/Ice/ServantLocator.h ../../include/Ice/Current.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/IdentityUtil.h ../IceStorm/Parser.h ../../include/IceStorm/IceStorm.h ../../include/Ice/Outgoing.h ../../include/Ice/BasicStream.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../../include/Ice/Direct.h ../../include/IceUtil/Functional.h +WeightedGraph.o: WeightedGraph.cpp ../IceStorm/WeightedGraph.h +Parser.o: Parser.cpp ../../include/Ice/Ice.h ../../include/Ice/Initialize.h ../../include/Ice/CommunicatorF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalException.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/PropertiesF.h ../../include/Ice/InstanceF.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/Stream.h ../../include/Ice/Communicator.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/UserExceptionFactoryF.h ../../include/Ice/StreamF.h ../../include/Ice/ObjectFactory.h ../../include/Ice/UserExceptionFactory.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/Identity.h ../../include/Ice/ServantLocator.h ../../include/Ice/Current.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/IdentityUtil.h ../IceStorm/Parser.h ../../include/IceStorm/IceStorm.h ../../include/Ice/Outgoing.h ../../include/Ice/BasicStream.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../../include/Ice/Direct.h ../IceStorm/WeightedGraph.h diff --git a/cpp/src/IceStorm/Admin.cpp b/cpp/src/IceStorm/Admin.cpp index 53faa5f2089..527564fc749 100644 --- a/cpp/src/IceStorm/Admin.cpp +++ b/cpp/src/IceStorm/Admin.cpp @@ -12,6 +12,8 @@ #include <IceStorm/Parser.h> #include <fstream> +#include <util/PlatformUtils.hpp> + using namespace std; using namespace Ice; using namespace IceStorm; @@ -27,9 +29,24 @@ public: int main(int argc, char* argv[]) { + try + { + XMLPlatformUtils::Initialize(); + } + catch(const XMLException& e) + { + cout << e.getMessage() << endl; + return EXIT_FAILURE; + } + addArgumentPrefix("IceStorm"); + Client app; - return app.main(argc, argv); + int rc = app.main(argc, argv); + + XMLPlatformUtils::Terminate(); + + return rc; } void diff --git a/cpp/src/IceStorm/Grammar.y b/cpp/src/IceStorm/Grammar.y index 683f698c4b0..3675ea83e5d 100644 --- a/cpp/src/IceStorm/Grammar.y +++ b/cpp/src/IceStorm/Grammar.y @@ -34,6 +34,8 @@ yyerror(const char* s) %token ICE_STORM_LIST %token ICE_STORM_SHUTDOWN %token ICE_STORM_LINK +%token ICE_STORM_UNLINK +%token ICE_STORM_GRAPH %token ICE_STORM_STRING %% @@ -83,9 +85,22 @@ command { parser->link($2); } +| ICE_STORM_UNLINK strings ';' +{ + parser->unlink($2); +} +| ICE_STORM_GRAPH strings ';' +{ + parser->graph($2); +} | ICE_STORM_LIST ';' { - parser->listAll(); + std::list<std::string> args; + parser->dolist(args); +} +| ICE_STORM_LIST strings ';' +{ + parser->dolist($2); } | ICE_STORM_SHUTDOWN ';' { diff --git a/cpp/src/IceStorm/LinkInfo.ice b/cpp/src/IceStorm/LinkDB.ice index 7645d9bf7f4..cf79afa5d64 100644 --- a/cpp/src/IceStorm/LinkInfo.ice +++ b/cpp/src/IceStorm/LinkDB.ice @@ -18,13 +18,13 @@ module IceStorm /** * - * Use to store persistent information on Topic federation. + * Used to store persistent information for Topic federation. * **/ -struct LinkInfo +struct LinkDB { TopicLink* obj; - int cost; + LinkInfo info; }; }; // End module IceStorm diff --git a/cpp/src/IceStorm/LinkSubscriber.cpp b/cpp/src/IceStorm/LinkSubscriber.cpp index 320e453ba6b..36685402b7a 100644 --- a/cpp/src/IceStorm/LinkSubscriber.cpp +++ b/cpp/src/IceStorm/LinkSubscriber.cpp @@ -19,7 +19,7 @@ using namespace std; LinkSubscriber::LinkSubscriber(const TraceLevelsPtr& traceLevels, const TopicLinkPrx& obj, Ice::Int cost) : Subscriber(traceLevels, obj->ice_getIdentity()), - _obj(TopicLinkPrx::checkedCast(obj->ice_batchOneway())), + _obj(TopicLinkPrx::uncheckedCast(obj->ice_batchOneway())), _cost(cost) { } diff --git a/cpp/src/IceStorm/Makefile b/cpp/src/IceStorm/Makefile index 2417060111b..5131471a342 100644 --- a/cpp/src/IceStorm/Makefile +++ b/cpp/src/IceStorm/Makefile @@ -33,13 +33,14 @@ SOBJS = TraceLevels.o \ TopicManagerI.o \ StringBoolDict.o \ IdentityLinkDict.o \ - LinkInfo.o \ + LinkDB.o \ IceStormInternal.o \ Server.o AOBJS = Admin.o \ Grammar.o \ Scanner.o \ + WeightedGraph.o \ Parser.o SRCS = $(OBJS:.o=.cpp) \ @@ -53,7 +54,7 @@ SLICE2FREEZECMD = $(SLICE2FREEZE) --include-dir IceStorm -I$(slicedir) -I.. include $(top_srcdir)/config/Make.rules -CPPFLAGS := -I.. $(CPPFLAGS) +CPPFLAGS := -I.. $(CPPFLAGS) -I$(XERCESC)/include/xercesc LDFLAGS := $(LDFLAGS) -L$(DB)/lib $(VERSIONED_NAME): $(OBJS) @@ -95,17 +96,17 @@ StringBoolDict.h StringBoolDict.cpp: $(SLICE2FREEZE) clean:: rm -f StringBoolDict.h StringBoolDict.cpp -LinkInfo.h LinkInfo.cpp: $(SLICE2CPP) - rm -f LinkInfo.h LinkInfo.cpp - $(SLICECMD) LinkInfo.ice +LinkDB.h LinkDB.cpp: LinkDB.ice $(SLICE2CPP) + rm -f LinkDB.h LinkDB.cpp + $(SLICECMD) LinkDB.ice clean:: - rm -f LinkInfo.h LinkInfo.cpp + rm -f LinkDB.h LinkDB.cpp -IdentityLinkDict.h IdentityLinkDict.cpp: $(SLICE2FREEZE) +IdentityLinkDict.h IdentityLinkDict.cpp: ../IceStorm/LinkDB.ice $(slicedir)/Ice/Identity.ice $(SLICE2FREEZE) rm -f IdentityLinkDict.h IdentityLinkDict.cpp - $(SLICE2FREEZECMD) --dict IceStorm::IdentityLinkDict,Ice::Identity,IceStorm::LinkInfo IdentityLinkDict \ - ../IceStorm/LinkInfo.ice $(slicedir)/Ice/Identity.ice + $(SLICE2FREEZECMD) --dict IceStorm::IdentityLinkDict,Ice::Identity,IceStorm::LinkDB IdentityLinkDict \ + ../IceStorm/LinkDB.ice $(slicedir)/Ice/Identity.ice clean:: rm -f IdentityLinkDict.h IdentityLinkDict.cpp diff --git a/cpp/src/IceStorm/Parser.cpp b/cpp/src/IceStorm/Parser.cpp index 723d048b97b..5142272bed0 100644 --- a/cpp/src/IceStorm/Parser.cpp +++ b/cpp/src/IceStorm/Parser.cpp @@ -10,6 +10,7 @@ #include <Ice/Ice.h> #include <IceStorm/Parser.h> +#include <IceStorm/WeightedGraph.h> #include <algorithm> @@ -45,14 +46,13 @@ Parser::usage() "exit, quit Exit this program.\n" "create TOPICS Add TOPICS.\n" "destroy TOPICS Remove TOPICS.\n" - "link FROM TO COST Link topics with the give COST.\n" - "list List all server descriptions.\n" + "link FROM TO COST Link FROM to TO with the given COST.\n" + "unlink FROM TO Unlink TO from FROM.\n" + "graph DATA COST Construct the link graph as described in DATA with COST\n" + "list [TOPICS] Display information on TOPICS or all topics.\n" "shutdown Shut the IceStorm server down.\n"; } -#include <IceUtil/Functional.h> -#include <functional> - void Parser::create(const list<string>& args) { @@ -145,23 +145,221 @@ Parser::link(const list<string>& _args) } void -Parser::listAll() +Parser::unlink(const list<string>& _args) +{ + list<string> args = _args; + + if (args.size() != 2) + { + error("`unlink' requires exactly two arguments (type `help' for more info)"); + return; + } + + try + { + TopicPrx fromTopic; + TopicPrx toTopic; + + try + { + fromTopic = _admin->retrieve(args.front()); + } + catch(const IceStorm::NoSuchTopic&) + { + ostringstream s; + s << args.front() << ": topic doesn't exist"; + error(s.str()); + return; + } + args.pop_front(); + + try + { + toTopic = _admin->retrieve(args.front()); + } + catch(const IceStorm::NoSuchTopic&) + { + ostringstream s; + s << args.front() << ": topic doesn't exist"; + error(s.str()); + return; + } + + fromTopic->unlink(toTopic); + } + catch(const Exception& ex) + { + ostringstream s; + s << ex; + error(s.str()); + } +} + +void +Parser::dolist(const list<string>& _args) { + list<string> args = _args; + try { + if (args.size() == 0) + { + TopicDict d = _admin->retrieveAll(); + if (!d.empty()) + { + for (TopicDict::iterator i = d.begin(); i != d.end(); ++i) + { + if (i != d.begin()) + { + cout << ", "; + } + cout << i->first; + } + cout << endl; + } + } + else + { + while (args.size() != 0) + { + string name = args.front(); + args.pop_front(); + cout << name << endl; + try + { + TopicPrx topic = _admin->retrieve(name); + LinkInfoSeq links = topic->getLinkInfoSeq(); + for (LinkInfoSeq::const_iterator p = links.begin(); p != links.end(); ++p) + { + cout << "\t" << (*p).name << " with cost " << (*p).cost << endl; + } + } + catch(const NoSuchTopic&) + { + cout << "\tNo such topic" << endl; + } + } + } + } + catch(const Exception& ex) + { + ostringstream s; + s << ex; + error(s.str()); + } +} + +void +Parser::graph(const list<string>& _args) +{ + list<string> args = _args; + + if (args.size() != 2) + { + error("`graph' requires exactly two arguments (type `help' for more info)"); + return; + } + + string file = args.front(); + args.pop_front(); + int maxCost = atoi(args.front().c_str()); + if (maxCost == 0) + { + error("`graph': cost must be a positive number"); + return; + } + + + try + { + WeightedGraph graph; + if (!graph.parse(file)) + { + cerr << file << ": parse failed" << endl; + return; + } + + + // + // Compute the new edge set. + // + vector<int> edges; + graph.compute(edges, maxCost); + graph.swap(edges); + + // + // Ensure each vertex is present. + // + vector<string> vertices = graph.getVertices(); TopicDict d = _admin->retrieveAll(); - if (!d.empty()) + vector<string>::const_iterator p; + + for (p = vertices.begin(); p != vertices.end(); ++p) { - for (TopicDict::iterator i = d.begin(); i != d.end(); ++i) + if (d.find(*p) == d.end()) { - if (i != d.begin()) + cout << *p << ": referenced topic not found" << endl; + return; + } + } + + int links = 0; + int unlinks = 0; + + // + // Get the edge set for reach vertex. + // + for (p = vertices.begin(); p != vertices.end(); ++p) + { + TopicPrx topic = d[*p]; + assert(topic); + LinkInfoSeq seq = topic->getLinkInfoSeq(); + + vector<pair<string, int> > edges = graph.getEdgesFor(*p); + for (vector<pair<string, int> >::const_iterator q = edges.begin(); q != edges.end(); ++q) + { + bool link = true; + for (LinkInfoSeq::iterator r = seq.begin(); r != seq.end(); ++r) { - cout << ", "; + // + // Found the link element. + // + if ((*r).name == (*q).first) + { + // + // If the cost is the same, then there is + // nothing to do. + // + if ((*r).cost == (*q).second) + { + link = false; + } + seq.erase(r); + break; + } } - cout << i->first; + + // + // Else, need to rebind the link. + // + if (link) + { + TopicPrx target = d[(*q).first]; + ++links; + topic->link(target, (*q).second); + } + } + + // + // The remainder of the links are obsolete. + // + for (LinkInfoSeq::const_iterator r = seq.begin(); r != seq.end(); ++r) + { + ++unlinks; + topic->unlink((*r).topic); } - cout << endl; } + cout << "graph: " << links << " new or changed links. " << unlinks << " unlinks." << endl; } catch(const Exception& ex) { diff --git a/cpp/src/IceStorm/Parser.h b/cpp/src/IceStorm/Parser.h index af642741552..781b515b7fd 100644 --- a/cpp/src/IceStorm/Parser.h +++ b/cpp/src/IceStorm/Parser.h @@ -45,14 +45,12 @@ int yyparse(); namespace IceStorm { +// +// Forward declaration. +// class Parser; typedef ::IceUtil::Handle<Parser> ParserPtr; -} - -namespace IceStorm -{ - class Parser : public ::IceUtil::SimpleShared { public: @@ -63,8 +61,10 @@ public: void create(const std::list<std::string>&); void destroy(const std::list<std::string>&); - void listAll(); + void dolist(const std::list<std::string>&); // Don't name list - conflicts with std::list void link(const std::list<std::string>&); + void unlink(const std::list<std::string>&); + void graph(const std::list<std::string>&); void shutdown(); void getInput(char*, int&, int); @@ -97,6 +97,6 @@ private: extern Parser* parser; // The current parser for bison/flex -} +} // End namespace IceStorm #endif diff --git a/cpp/src/IceStorm/Scanner.l b/cpp/src/IceStorm/Scanner.l index fc57979eed7..bddcaf41b71 100644 --- a/cpp/src/IceStorm/Scanner.l +++ b/cpp/src/IceStorm/Scanner.l @@ -112,6 +112,14 @@ NL [\n] return ICE_STORM_LINK; } +"unlink" { + return ICE_STORM_UNLINK; +} + +"graph" { + return ICE_STORM_GRAPH; +} + "shutdown" { return ICE_STORM_SHUTDOWN; } diff --git a/cpp/src/IceStorm/TopicI.cpp b/cpp/src/IceStorm/TopicI.cpp index f46b312bf01..caf9631e323 100644 --- a/cpp/src/IceStorm/TopicI.cpp +++ b/cpp/src/IceStorm/TopicI.cpp @@ -323,7 +323,7 @@ TopicI::TopicI(const Ice::ObjectAdapterPtr& adapter, const TraceLevelsPtr& trace _link = new TopicLinkI(_subscribers); id.name = "link"; - _linkPrx = TopicLinkPrx::checkedCast(_adapter->add(_link, id)); + _linkPrx = TopicLinkPrx::uncheckedCast(_adapter->add(_link, id)); // // Run through link database - re-establishing linked subscribers @@ -337,7 +337,7 @@ TopicI::TopicI(const Ice::ObjectAdapterPtr& adapter, const TraceLevelsPtr& trace _traceLevels->logger->trace(_traceLevels->topicCat, s.str()); } - SubscriberPtr subscriber = _factory->createLinkSubscriber(p->second.obj, p->second.cost); + SubscriberPtr subscriber = _factory->createLinkSubscriber(p->second.obj, p->second.info.cost); _subscribers->add(subscriber); } } @@ -404,10 +404,11 @@ TopicI::link(const TopicPrx& topic, Ice::Int cost, const Ice::Current&) reap(); + string name = topic->getName(); if (_traceLevels->topic > 0) { ostringstream s; - s << _name << " link " << topic->getName() << " cost " << cost; + s << _name << " link " << name << " cost " << cost; _traceLevels->logger->trace(_traceLevels->topicCat, s.str()); } @@ -418,9 +419,11 @@ TopicI::link(const TopicPrx& topic, Ice::Int cost, const Ice::Current&) TopicLinkPrx link = internal->getLinkProxy(); Ice::Identity ident = link->ice_getIdentity(); - LinkInfo info; - info.obj = link; - info.cost = cost; + LinkDB dbInfo; + dbInfo.obj = link; + dbInfo.info.topic = topic; + dbInfo.info.name = name; + dbInfo.info.cost = cost; // // If the link already exists then remove the original subscriber. @@ -435,9 +438,9 @@ TopicI::link(const TopicPrx& topic, Ice::Int cost, const Ice::Current&) _subscribers->unsubscribe(ident); } - _links.insert(make_pair(ident, info)); + _links.insert(make_pair(ident, dbInfo)); - SubscriberPtr subscriber = _factory->createLinkSubscriber(info.obj, info.cost); + SubscriberPtr subscriber = _factory->createLinkSubscriber(dbInfo.obj, dbInfo.info.cost); _subscribers->add(subscriber); } @@ -477,6 +480,29 @@ TopicI::unlink(const TopicPrx& topic, const Ice::Current&) } } +LinkInfoSeq +TopicI::getLinkInfoSeq(const Ice::Current&) +{ + JTCSyncT<JTCRecursiveMutex> sync(*this); + + if (_destroyed) + { + throw Ice::ObjectNotExistException(__FILE__, __LINE__); + } + + reap(); + + LinkInfoSeq seq; + + for (IdentityLinkDict::const_iterator p = _links.begin(); p != _links.end(); ++p) + { + LinkInfo info = p->second.info; + seq.push_back(info); + } + + return seq; +} + TopicLinkPrx TopicI::getLinkProxy(const Ice::Current&) { diff --git a/cpp/src/IceStorm/TopicI.h b/cpp/src/IceStorm/TopicI.h index 0b83984281f..6c72906a789 100644 --- a/cpp/src/IceStorm/TopicI.h +++ b/cpp/src/IceStorm/TopicI.h @@ -47,6 +47,7 @@ public: virtual void destroy(const Ice::Current&); virtual void link(const TopicPrx&, Ice::Int, const Ice::Current&); virtual void unlink(const TopicPrx&, const Ice::Current&); + virtual LinkInfoSeq getLinkInfoSeq(const Ice::Current&); virtual TopicLinkPrx getLinkProxy(const Ice::Current&); diff --git a/cpp/src/IceStorm/WeightedGraph.cpp b/cpp/src/IceStorm/WeightedGraph.cpp new file mode 100644 index 00000000000..eb2453ec156 --- /dev/null +++ b/cpp/src/IceStorm/WeightedGraph.cpp @@ -0,0 +1,426 @@ +// ********************************************************************** +// +// Copyright (c) 2001 +// MutableRealms, Inc. +// Huntsville, AL, USA +// +// All Rights Reserved +// +// ********************************************************************** + +#include <map> +#include <list> +#include <iostream> + +#include <assert.h> + +#include <parsers/SAXParser.hpp> +#include <sax/HandlerBase.hpp> + +#include <IceStorm/WeightedGraph.h> + +using namespace std; +using namespace IceStorm; + +namespace IceStorm +{ + +class SAXErrorHandler : public ErrorHandler +{ +public: + + void + warning(const SAXParseException& exception) + { + char* s = XMLString::transcode(exception.getMessage()); + cerr << "warning: " << s << endl; + delete[] s; + } + + void + error(const SAXParseException& exception) + { + char* s = XMLString::transcode(exception.getMessage()); + cerr << "error: " << s << endl; + delete[] s; + } + + void + fatalError(const SAXParseException& exception) + { + char* s = XMLString::transcode(exception.getMessage()); + cerr << "fatal:" << s << endl; + delete[] s; + } + + void + resetErrors() + { + } +}; + +class SAXGraphHandler : public DocumentHandler +{ +public: + + SAXGraphHandler(WeightedGraph& graph) : + _graph(graph) + { + } + + ~SAXGraphHandler() + { + } + + virtual void characters(const XMLCh *const chars, const unsigned int length) { } + virtual void endDocument() { } + virtual void endElement(const XMLCh *const name) { } + virtual void ignorableWhitespace(const XMLCh *const chars, const unsigned int length) { } + virtual void processingInstruction(const XMLCh *const target, const XMLCh *const data) { } + virtual void resetDocument() { } + virtual void setDocumentLocator(const Locator *const locator) { } + virtual void startDocument() { } + virtual void startElement(const XMLCh *const name, AttributeList &attrs); + +private: + + WeightedGraph& _graph; +}; + +// +// Exception during parsing. +// +struct WeightedGraphParseException +{ + std::string reason; +}; + +} // End namespace IceStorm + +void +SAXGraphHandler::startElement(const XMLCh *const name, AttributeList &attrs) +{ + char* str = XMLString::transcode(name); + + try + { + if (strcmp(str, "vertex") == 0) + { + XMLCh* n = XMLString::transcode("name"); + const XMLCh* value = attrs.getValue(n); + delete[] n; + if (value == 0) + { + WeightedGraphParseException ex; + ex.reason = "<vertex> name attribute missing"; + throw ex; + } + + char* vstr = XMLString::transcode(value); + + _graph.addVertex(vstr); + + delete[] vstr; + } + else if (strcmp(str, "edge") == 0) + { + XMLCh* n = XMLString::transcode("source"); + const XMLCh* value = attrs.getValue(n); + delete[] n; + if (value == 0) + { + WeightedGraphParseException ex; + ex.reason = "<edge> source attribute missing"; + throw ex; + } + + char* source = XMLString::transcode(value); + n = XMLString::transcode("target"); + value = attrs.getValue(n); + delete[] n; + if (value == 0) + { + delete[] source; + WeightedGraphParseException ex; + ex.reason = "<edge> target attribute missing"; + throw ex; + } + char* target = XMLString::transcode(value); + n = XMLString::transcode("cost"); + value = attrs.getValue(n); + delete[] n; + + int cost = 0; + if (value != 0) + { + char* cstr = XMLString::transcode(value); + cost = atoi(cstr); + delete[] cstr; + } + + try + { + _graph.addEdge(source, target, cost); + } + catch(...) + { + delete[] source; + delete[] target; + throw; + } + } + } + catch(const WeightedGraphParseException& ex) + { + // + // Xerces eats all exceptions (apparently by design). Not sure + // how the error handling is supposed to work. + // + cerr << ex.reason << endl; + _graph.error(); + delete[] str; + } + catch(...) + { + _graph.error(); + delete[] str; + } + delete[] str; +} + +WeightedGraph::WeightedGraph(bool reflective) : + _reflective(reflective) +{ +} + +WeightedGraph::~WeightedGraph() +{ +} + +bool +WeightedGraph::parse(const string& xmlFile) +{ + _error = 0; + SAXParser* parser = new SAXParser; + parser->setValidationScheme(SAXParser::Val_Never); + + try + { + SAXErrorHandler err; + SAXGraphHandler handler(*this); + parser->setDocumentHandler(&handler); + parser->setErrorHandler(&err); + parser->parse(xmlFile.c_str()); + } + catch(const XMLException& e) + { + cerr << e.getMessage() << endl; + } + int rc = parser->getErrorCount(); + delete parser; + + return _error == 0 && rc == 0; +} + +void +WeightedGraph::dump(ostream& os) +{ + for (unsigned int i = 0 ; i < _vertices.size(); ++i) + { + for (unsigned int j = 0; j < _vertices.size(); ++j) + { + os << _edges[i*_vertices.size() + j] << " "; + } + os << endl; + } +} + +void +WeightedGraph::swap(const std::vector<int>& edges) +{ + assert(edges.size() == _edges.size()); + _edges = edges; +} + +vector<string> +WeightedGraph::getVertices() const +{ + return _vertices; +} + +vector<pair<string, int> > +WeightedGraph::getEdgesFor(const std::string& vertex) const +{ + vector<pair<string, int> > edges; + + map<std::string, int>::const_iterator p = _vlookup.find(vertex); + if (p != _vlookup.end()) + { + int row = p->second * _vertices.size(); + for (unsigned int i = row; i < row + _vertices.size(); ++i) + { + if (_edges[i] != -1) + { + edges.push_back(make_pair(_vertices[i-row], _edges[i])); + } + } + } + + return edges; +} + +void +WeightedGraph::compute(vector<int>& newEdges, int max) +{ + // + // Reinitialize the adjacency matrix. + // + newEdges.clear(); + newEdges.resize(_vertices.size()*_vertices.size(), -1); + + // + // For each vertex calculate the cost for all reachable vertexes + // within the given max cost. + // + for (unsigned int i = 0; i < _vertices.size(); ++i) + { + // + // List of <vertex-index,cost> pairs. + // + list<pair<unsigned int, int> > visited; + + visit(i, 0, visited, max); + + // + // Add each vertex-index/cost pair to the new adjacency + // matrix. + // + for (list<pair<unsigned int, int> >::iterator p = visited.begin(); p != visited.end(); ++p) + { + // + // Ignore loops. + // + if ((*p).first != i) + { + newEdges[i*_vertices.size() + (*p).first] = (*p).second; + if (_reflective) + { + newEdges[(*p).first*_vertices.size() + i] = (*p).second; + } + } + } + } +} + +void +WeightedGraph::visit(unsigned int vertex, int cost, list<pair<unsigned int, int> >& visited, int max) +{ + // + // Is the given vertex already in the visited list? If so, then + // check that is the cost is minimal cost and replace if not. + // + for ( list<pair<unsigned int, int> >::iterator p = visited.begin(); p != visited.end(); ++p) + { + if (p->first == vertex) + { + if (p->second > cost) + { + p->second = cost; + } + return; + } + } + + // + // Add the vertex to the visited set (with the cost to visit). + // + visited.push_back(make_pair(vertex, cost)); + + // + // Run through each edges for this vertex (that's a row in the + // adjacency matrix). + // + int row = vertex * _vertices.size(); + for (unsigned int i = row ; i < row + _vertices.size() ; ++i) + { + if (_edges[i] != -1) + { + if (cost + _edges[i] <= max) + { + visit(i - row, cost + _edges[i], visited, max); + } + } + } +} + +void +WeightedGraph::addVertex(const string& name) +{ + _vertices.push_back(name); +} + +void +WeightedGraph::addEdge(const string& from, const string& to, int cost) +{ + // + // Loops are not permitted. + // + if (from == to) + { + WeightedGraphParseException ex; + ex.reason = "loops are not permitted"; + throw ex; + } + + if (_edges.size() == 0) + { + // + // Prepare the edge map + // + _edges.resize(_vertices.size()*_vertices.size(), -1); + for (unsigned int i = 0; i < _vertices.size(); ++i) + { + _vlookup.insert(make_pair(_vertices[i], i)); + } + } + + // + // Location of from and to. + // + map<string, int>::iterator p = _vlookup.find(from); + if (p == _vlookup.end()) + { + WeightedGraphParseException ex; + ex.reason = "<edge> vertex " + from + " not found"; + throw ex; + } + + int fidx = p->second; + p = _vlookup.find(to); + if (p == _vlookup.end()) + { + WeightedGraphParseException ex; + ex.reason = "<edge> vertex " + to + " not found"; + throw ex; + } + int tidx = p->second; + + // + // Fill in from, to - to,from + // + _edges[fidx*_vertices.size() + tidx] = cost; + if (_reflective) + { + _edges[tidx*_vertices.size() + fidx] = cost; + } +} + +void +WeightedGraph::error() +{ + // + // An error occurred during the semantic handling of the document. + // + ++_error; +} + diff --git a/cpp/src/IceStorm/WeightedGraph.h b/cpp/src/IceStorm/WeightedGraph.h new file mode 100644 index 00000000000..88dcf17d16c --- /dev/null +++ b/cpp/src/IceStorm/WeightedGraph.h @@ -0,0 +1,115 @@ +// ********************************************************************** +// +// Copyright (c) 2001 +// MutableRealms, Inc. +// Huntsville, AL, USA +// +// All Rights Reserved +// +// ********************************************************************** + +#ifndef WEIGHTED_GRAPH_H +#define WEIGHTED_GRAPH_H + +#include <vector> +#include <list> +#include <map> + +namespace IceStorm +{ + +// +// Forward declaration. +// +class SAXGraphHandler; + +// +// A weighted graph. This class uses internally a vertex, adjacency +// matrix representation. Each vertex has a name. The [i,j] of the +// adjacency graph represents the the edge from _vertices[i] to +// _vertices[j]. +// +class WeightedGraph +{ +public: + + WeightedGraph(bool = false); + ~WeightedGraph(); + + // + // Parse the graph from the given XML file. Returns false in event + // of a parse error. + // + bool parse(const std::string&); + + // + // Compute a new adjacency matrix with the given cost. + // + void compute(std::vector<int>&, int); + + // + // Render the edge table in ASCII format. + // + void dump(std::ostream&); + + // + // Swap the adjacency matrix. This could be actual swap. + // + void swap(const std::vector<int>&); + + // + // Get all the vertices. + // + std::vector<std::string> getVertices() const; + + // + // Get the set of edges for a vertex. The return data is the name + // of the second vertex, and the cost. + // + std::vector<std::pair<std::string, int> > getEdgesFor(const std::string&) const; + +private: + + // + // Recursive function used in computation of new edge set. + // + void visit(unsigned int, int, std::list<std::pair<unsigned int, int> >&, int); + + // + // Callbacks from parsing routines + // + void addVertex(const std::string&); + void addEdge(const std::string&, const std::string&, int); + + void error(); + + // + // List of vertices. + // + std::vector<std::string> _vertices; + + // + // Lookup table - maps from vertex name to vertex index. + // + std::map<std::string, int> _vlookup; + + // + // The adjacency matrix. -1 indicates no edge, otherwise the value + // is the cost. + // + std::vector<int> _edges; + + // + // Is the graph reflective? That is if there is edge (v1, v2, + // cost) then there is (v2, v1, cost). + // + bool _reflective; + + int _error; + + friend class SAXGraphHandler; +}; + +} // End namespace IceStorm + +#endif diff --git a/cpp/src/IceStorm/graph-sample.xml b/cpp/src/IceStorm/graph-sample.xml new file mode 100644 index 00000000000..8857f83829a --- /dev/null +++ b/cpp/src/IceStorm/graph-sample.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="iso-8859-1"?> + +<graph> + <vertex-set> + <vertex name="fed1"/> + <vertex name="fed2"/> + <vertex name="fed3"/> + </vertex-set> + <edge-set> + <edge source="fed1" target="fed2" cost="10"/> + <edge source="fed2" target="fed3" cost="5"/> + </edge-set> +</graph> |