00001
00002
00003
00004
00005 #ifndef __PWVSTREAM_H
00006 #define __PWVSTREAM_H
00007
00008 #include "iwvstream.h"
00009 #include "wvstream.h"
00010 #include "wvstreamclone.h"
00011 #include "wvmoniker.h"
00012 #include "wvtr1.h"
00013
00036 class PWvStream : public wv::shared_ptr<WvStream>
00037 {
00038 static WvStream *clean_stream(IWvStream *s)
00039 {
00040 WvStream *ss = dynamic_cast<WvStream *>(s);
00041 if (ss)
00042 return ss;
00043 else
00044 return new WvStreamClone(s);
00045 }
00046
00047 static WvStream *make_stream(WvStringParm moniker, IObject *obj)
00048 {
00049 IWvStream *s = IWvStream::create(moniker, obj);
00050 if (!s)
00051 s = wvcreate<IWvStream>("null:");
00052 assert(s != NULL);
00053 return clean_stream(s);
00054 }
00055
00056 public:
00057 PWvStream()
00058 {
00059
00060
00061 }
00062
00063 PWvStream(IWvStream *s)
00064 : wv::shared_ptr<WvStream>(clean_stream(s),
00065 wv::bind(&IWvStream::release, _1))
00066 {
00067 }
00068
00069 PWvStream(WvStringParm moniker, IObject *obj = 0)
00070 : wv::shared_ptr<WvStream>(make_stream(moniker, obj),
00071 wv::bind(&IWvStream::release, _1))
00072 {
00073
00074
00075 }
00076
00077 WvStream *addRef() const
00078 {
00079 if (get())
00080 get()->addRef();
00081 return get();
00082 }
00083 };
00084
00085 #endif // __PWVSTREAM_H