00001 /* Copyright (c) 2007, Gennady Bystritsky <bystr@mac.com> 00002 * 00003 * Distributed under the MIT Licence. 00004 * This is free software. See 'LICENSE' for details. 00005 * You must read and accept the license prior to use. 00006 */ 00007 00008 #ifndef _SK_RT_CONFIG_SPOTLOCATOR_ 00009 #define _SK_RT_CONFIG_SPOTLOCATOR_ 00010 00011 #include <sk/rt/config/Locator.h> 00012 #include <sk/rt/config/NamedStreamOpener.h> 00013 00014 #include <sk/util/String.h> 00015 #include <sk/util/Holder.hxx> 00016 00017 namespace sk { 00018 namespace rt { 00019 namespace config { 00020 class SpotLocator 00021 : public virtual Locator, 00022 public virtual NamedStreamOpener 00023 { 00024 public: 00025 SpotLocator(const sk::util::String& item, const sk::util::String& location, const SpotLocator& other); 00026 SpotLocator(const sk::util::String& item, const sk::util::String& location); 00027 SpotLocator(const sk::util::String& location, const SpotLocator& other); 00028 SpotLocator(const SpotLocator& other); 00029 virtual ~SpotLocator(); 00030 00031 static void setStreamOpener(const NamedStreamOpener& opener); 00032 static void clearStreamOpener(); 00033 00034 // sk::rt::config::Locator implementation. 00035 void invoke(const StreamProcessor& processor) const; 00036 00037 // sk::util::Object re-implementation. 00038 const sk::util::Class getClass() const; 00039 00040 protected: 00041 static const SpotLocator DUMMY; 00042 00043 private: 00044 SpotLocator(); 00045 SpotLocator& operator = (const SpotLocator& other); 00046 00047 // sk::rt::config::NamedStreamOpener imlementation. 00048 std::istream* openStream(const sk::util::String& name) const; 00049 00050 void becomeDummy(); 00051 bool isDummy() const; 00052 const NamedStreamOpener& getStreamOpener() const; 00053 00054 const sk::util::String _item; 00055 const sk::util::String _location; 00056 sk::util::Holder<SpotLocator> _locatorHolder; 00057 00058 static sk::util::Holder<const NamedStreamOpener> _streamOpenerHolder; 00059 }; 00060 } 00061 } 00062 } 00063 00064 #endif /* _SK_RT_CONFIG_SPOTLOCATOR_ */