void CCache::PutValue(const std::wstring& idx, const std::wstring& key, const variant_t& val) { if (val.is_object()) { com_ptr<IUnknown> unk = com_cast(val); if (unk) if (!is_object_aggregating_ftm( unk )) { throw std::runtime_error("Cache can only store apartment neutral objects"); } } auto_cs lock(cs_); datetime_t now = datetime_t::now(); MAP::iterator it = map_.find(idx); if (it == map_.end()) { map_[idx].submap[key] = val; map_[idx].timestamp = now; } else { // delete old time stamp heap_.erase( it->second.timestamp ); // update existing value it->second.timestamp = now; it->second.submap[key] = val; } // add time stamp heap_.insert( std::make_pair(now, idx) ); }
/** * Ask windowed OLE container for its window handle. * * There are different types of OLE object with which could support this * operation. Try them in turn until one works. * * @todo Add more supported OLE object types. */ inline boost::optional< washer::window::window<wchar_t> > window_from_ole_window( comet::com_ptr<IUnknown> ole_window) { HWND hwnd = NULL; if (comet::com_ptr<IOleWindow> window = com_cast(ole_window)) { window->GetWindow(&hwnd); } else if (comet::com_ptr<IShellView> view = com_cast(ole_window)) { view->GetWindow(&hwnd); } if (hwnd) return washer::window::window<wchar_t>( washer::window::window_handle::foster_handle(hwnd)); else return boost::optional< washer::window::window<wchar_t> >(); }