On Tuesday 28 May 2002 4:40 pm, Andre Poenitz wrote: > On Tue, May 28, 2002 at 01:00:09PM +0100, Angus Leeming wrote: > > > Unrelated question: Why are there boost::shared_ptr<> al over the > > > place? Sort of 'pimpl'? > > > > Where. I don't have the source to hand remember. > > /// The cache contains data of this type. > typedef boost::shared_ptr<GCacheItem> CacheItemType; > > /** The cache contains one item per file, so use a map to find the > * cache item quickly by filename. > * Note that each cache item can have multiple views, potentially one > * per inset that references the original file. > */ > typedef std::map<string, CacheItemType> CacheType;
When the map is deleted then so is the GCacheItem it's storing. The string key allows me to find the GCacheItem by filename. If we changed things around so that all that ModifiedItem stuff was moved to InsetGraphics, then you could probably store the Cache as a list<CacheItemType>, so long as you passed back a pointer to the CacheItem for the InsetGraphics to store. I believe boost now has a smart pointer that just references an existing pointer; can't remember its name. It sounded like it was made for such a case. If there are no references to a CacheItem, then remove it from the list. > > > Next question: Why is GCacheItem derived from SigC::Object? Shouldn't > > > it rather have signals as members? > > > > Because the graphics converter emits a signal when the file is converted > > to a loadable format. We want to know when to load it don't we? > > Ok. I probably just don't understand the significance of being an > SigC::Object. > > Being an SigC::Object means I can receive signals? One or any number? Yes. It means that you can define its methods as SLOTs. Deriving from SigC::Object means that SigC is sure that the instance of the class whose method it is to call still exists. Signals don't need such checks, because if the signal is deleted it can't emit much ;-) > [How does this relate to the boost signals (of which I read > something _very_ recently...;-}] I am hazy, but seem to recall that boost mentions this very thing in the documentation. Angus