///////////////////////////////////////////////////////////////////////////// // CAggregate::QueryInterface // ///////////////////////////////////////////////////////////////////////////// HRESULT CAggregate::QueryInterface(REFIID riid, LPVOID *ppv) { HRESULT hr = S_OK; //TEST_ NULL if(ppv == NULL) return E_INVALIDARG; *ppv = NULL; //Support IID_IUnknown if(riid == IID_IUnknown) { *ppv = (IUnknown*)this; SAFE_ADDREF((IUnknown*)*ppv); } else if(riid == IID_IAggregate) { *ppv = (IUnknown*)this; SAFE_ADDREF((IUnknown*)*ppv); } else if(m_spUnkInner) { //Delegate the the Inner Object //This is not "circular" since this interface is the IID_IUnknown //interface only, which has its own non-delegating QI... hr = m_spUnkInner->QueryInterface(riid, ppv); } else { return E_NOINTERFACE; } return hr; }
MgdCreateFileFeatureSource::MgdCreateFileFeatureSource( MgResourceIdentifier* resource, MgFileFeatureSourceParams* params) { m_resource = resource; SAFE_ADDREF(resource); m_params = params; SAFE_ADDREF(params); }
////////////////////////////////////////////////////////////// // Create and initialize an MgdMapPlot instance. MgdMapPlot::MgdMapPlot(MgdMap* map, MgdPlotSpecification* plotSpec, MgdLayout* layout) { if (NULL == map || NULL == plotSpec) { throw new MgNullArgumentException(L"MgdMapPlot.MgdMapPlot", __LINE__, __WFILE__, NULL, L"", NULL); } Initialize(); m_map = SAFE_ADDREF(map); m_plotSpec = SAFE_ADDREF(plotSpec); m_layout = SAFE_ADDREF(layout); m_plotInstruction = MgdMapPlotInstruction::UseMapCenterAndScale; }
//////////////////////////////////////////////////////// // CBase::CBase // //////////////////////////////////////////////////////// CBase::CBase(CBase* pCBase, LPUNKNOWN pUnkOuter) { m_cRef = 0; m_pCBase = pCBase; SAFE_ADDREF(m_pCBase); m_pUnkOuter = pUnkOuter ? pUnkOuter : this; //AddRef the parent object... //This is done since all Child objects in OLE DB have some way to //get back to the parent, Session -> DataSource, Rowset -> Command. //We need to addref the parent so its still active whenever needed to get back to if(m_pCBase) SAFE_ADDREF(m_pCBase->m_pUnkOuter); }
////////////////////////////////////////////////////////////// // Set the extent and expand to fit flag. void MgdMapPlot::SetExtent(MgEnvelope* extent, bool expandToFit) { SAFE_RELEASE(m_extent); m_extent = SAFE_ADDREF(extent); m_bExpandToFit = expandToFit; m_plotInstruction = MgdMapPlotInstruction::UseOverriddenExtent; }
MgdFeatureInfoRenderer::MgdFeatureInfoRenderer(MgdSelection* selection, int maxFeatures, double mapScale, double* point, SE_Renderer* impRenderer) : m_extents(0.0, 0.0, 1.0, 1.0), m_numFeatures(0), m_url(L""), m_tooltip(L""), m_props(NULL), m_layerId(L""), m_nMaxFeatures(maxFeatures), m_mapScale(mapScale), m_fcName(L""), m_mapInfo(NULL), m_layerInfo(NULL), m_fcInfo(NULL), m_pointTest(false), m_impRenderer(impRenderer) { m_selection = SAFE_ADDREF(selection); m_keyEncode = new KeyEncode(); if(point != NULL) { m_point[0] = point[0]; m_point[1] = point[1]; m_needPointTest = true; } else m_needPointTest = false; }
cParticleSystem::cParticleSystem(LPD3DXSPRITE pSprite) : m_fLifespan(0.0f) , m_fLifespanVar(0.0f) , m_fStartSize(0.0f) , m_fStartSizeVar(0.0f) , m_fFinishSize(0.0f) , m_fFinishSizeVar(0.0f) , m_fEmitterAngle(0.0f) , m_fEmitterAngleVar(0.0f) , m_fStartRot(0.0f) , m_fStartRotVar(0.0f) , m_fEndRot(0.0f) , m_fEndRotVar(0.0f) , m_fXVar(0.0f) , m_fYVar(0.0f) , m_fSpeed(0.0f) , m_fSpeedVar(0.0f) , m_fGravityX(0.0f) , m_fGravityY(0.0f) , m_fTanAcc(0.0f) , m_fTanAccVar(0.0f) , m_fRadAcc(0.0f) , m_fRadAccVar(0.0f) , m_dwStartColor(0) , m_dwStartColorVar(0) , m_dwFinishColor(0) , m_dwFinishColorVar(0) { SAFE_ADDREF(pSprite); m_pSprite = pSprite; }
MgByteReader* MgResourceDefinitionManager::GetRepository( MgResourceIdentifier* resource) { assert(NULL != resource && resource->IsRoot()); Ptr<MgByteReader> byteReader; MG_RESOURCE_SERVICE_TRY() // Get the resource. XmlDocument xmlDoc = GetDocument(*resource); // Create a byte reader. string document; xmlDoc.getContent(document); // TODO: Improve performance by using getContentAsXmlInputStream? Ptr<MgByteSource> byteSource = new MgByteSource( (unsigned char*)document.c_str(), (INT32)document.length()); byteSource->SetMimeType(MgMimeType::Xml); byteReader = byteSource->GetReader(); MG_RESOURCE_CONTAINER_CATCH_AND_THROW(L"MgResourceDefinitionManager.GetRepository") return SAFE_ADDREF((MgByteReader*)byteReader); }
////////////////////////////////////////////////////////////////// ///<summary> /// Construct a MgProxyFeatureReader object from a byte source ///</summary> ///<param name="byteSource">Byte source object</param> /// MgProxyFeatureReader::MgProxyFeatureReader(MgFeatureSet* featureSet) { m_currRecord = 0; m_serverfeatReader = L""; m_set = SAFE_ADDREF(featureSet); m_service = NULL; }
// ---------------------------------------------------------------------------- // Function: // CSwapPropPage::AddPages // // Description: // Implementation of IShellPropSheetExt::AddPages. Adds one or more pages // to a property sheet that the Shell displays for a file object. // // Parameters: // lpfnAddPage - [in] Address of a function that the property sheet // handler calls to add a page to the property sheet. The // function takes a property sheet handle returned by the // CreatePropertySheetPage function and the lParam parameter // passed to the AddPages method. // lParam - [in] Parameter to pass to the function specified by the // lpfnAddPage method. // // Return values: // Returns S_OK if successful. If the method fails, an OLE-defined error // code is returned // ---------------------------------------------------------------------------- _Use_decl_annotations_ HRESULT STDMETHODCALLTYPE CSwapPropPage::AddPages ( LPFNADDPROPSHEETPAGE lpfnAddPage, // See PrSht.h LPARAM lParam // Used by caller, don't modify ) { HRESULT hr = S_OK; PROPSHEETPAGE psp; HPROPSHEETPAGE hPage1 = NULL; AudioFXExtensionParams* pAudioFXParams = (AudioFXExtensionParams*)lParam; #pragma warning(push) #pragma warning(disable: 28197) AudioFXExtensionParams* pAudioFXParamsCopy = new AudioFXExtensionParams; #pragma warning(pop) if (pAudioFXParamsCopy == NULL) { return E_OUTOFMEMORY; } // Make a copy of the params CopyMemory(pAudioFXParamsCopy, pAudioFXParams, sizeof(AudioFXExtensionParams)); SAFE_ADDREF(pAudioFXParamsCopy->pFxProperties); // Initialize property page params and create page psp.dwSize = sizeof(psp); psp.dwFlags = PSP_USEREFPARENT | PSP_USECALLBACK; psp.hInstance = _AtlBaseModule.GetModuleInstance(); psp.hIcon = 0; psp.pcRefParent = (UINT*)&m_dwRef; psp.lParam = (LPARAM)pAudioFXParamsCopy; psp.pszTemplate = MAKEINTRESOURCE(IDD_SWAP_PROP_PAGE); psp.pfnDlgProc = (DLGPROC)DialogProcPage1; psp.pfnCallback = PropSheetPageProc; // Create the property sheet page and add the page hPage1 = CreatePropertySheetPage(&psp); if (hPage1) { if (!lpfnAddPage(hPage1, pAudioFXParams->AddPageParam)) { hr = E_FAIL; delete pAudioFXParamsCopy; DestroyPropertySheetPage(hPage1); } else { // Add ref for page this->AddRef(); } } else { delete pAudioFXParamsCopy; hr = E_OUTOFMEMORY; } return(hr); }
////////////////////////////////////////////////////////////////// /// <summary> /// Gets the DTime value of the specified property. No conversion is /// performed, thus the property must be a of date type or the result /// is NULL</summary> /// <param name="index">Property index.</param> /// <returns>Returns the DTime value.</returns> /// EXCEPTIONS: /// InvalidPropertyType MgDateTime* MgProxyFeatureReader::GetDateTime(INT32 index) { Ptr<MgDateTimeProperty> ptrProp = (MgDateTimeProperty*)GetProperty(index, MgPropertyType::DateTime); Ptr<MgDateTime> retVal = ptrProp->GetValue(); return SAFE_ADDREF((MgDateTime*)retVal); }
////////////////////////////////////////////////////////////////// /// <summary> /// Gets the DTime value of the specified property. No conversion is /// performed, thus the property must be a of date type or the result /// is NULL</summary> /// <param name="propertyName">Property name.</param> /// <returns>Returns the DTime value.</returns> /// EXCEPTIONS: /// InvalidPropertyType MgDateTime* MgProxyFeatureReader::GetDateTime(CREFSTRING propertyName) { Ptr<MgDateTimeProperty> ptrProp = (MgDateTimeProperty*)GetProperty(propertyName, MgPropertyType::DateTime); Ptr<MgDateTime> retVal = ptrProp->GetValue(); return SAFE_ADDREF((MgDateTime*)retVal); }
/// <summary> /// Constructor /// </summary> /// <param name="className"> /// Name of class from which data to be deleted /// </param> /// <param name="filterText"> /// Filter crieteria to be applied for deletion /// </param> /// <returns> /// Nothing /// </returns> MgInsertFeatures::MgInsertFeatures(CREFSTRING className, MgBatchPropertyCollection* propertyValues) { if (className.empty()) { MgStringCollection arguments; arguments.Add(L"1"); arguments.Add(MgResources::BlankArgument); throw new MgInvalidArgumentException(L"MgInsertFeatures.MgInsertFeatures", __LINE__, __WFILE__, &arguments, L"MgStringEmpty", NULL); } if (propertyValues == NULL) { throw new MgNullArgumentException(L"MgInsertFeatures.MgInsertFeatures", __LINE__, __WFILE__, NULL, L"", NULL); } if (propertyValues->GetCount() == 0) { MgStringCollection arguments; arguments.Add(L"2"); arguments.Add(L"0"); throw new MgInvalidArgumentException(L"MgInsertFeatures.MgInsertFeatures", __LINE__, __WFILE__, &arguments, L"MgPropertyValuesEmpty", NULL); } m_className = className; m_properties = SAFE_ADDREF(propertyValues); }
////////////////////////////////////////////////////////////// // Set the view center and scale. void MgdMapPlot::SetCenterAndScale(MgCoordinate* center, double scale) { SAFE_RELEASE(m_center); m_center = SAFE_ADDREF(center); m_scale = scale; m_plotInstruction = MgdMapPlotInstruction::UseOverriddenCenterAndScale; }
cSprite::cSprite(LPD3DXSPRITE pSprite) : m_pSprite(NULL) , m_pTexture(NULL) { SAFE_ADDREF(pSprite); m_pSprite = pSprite; m_dwColor = D3DCOLOR_ARGB(255, 255, 255, 255); }
// ---------------------------------------------------------------------------------------------- Texture::Texture(Texture* tex) { if(tex) { m_tex = tex->m_tex; m_view = tex->m_view; m_texType = tex->GetTextureType(); SAFE_ADDREF(m_tex); SAFE_ADDREF(m_view); } else { m_tex = NULL; m_view = NULL; m_texType = TextureType::Unknown; } }
MgdSqlDataReader::MgdSqlDataReader(MgdFeatureConnection* conn, FdoISQLDataReader* reader) { m_reader = FDO_SAFE_ADDREF(reader); m_connection = SAFE_ADDREF(conn); // The reader takes ownership of the FDO connection m_connection->OwnReader(); }
void MgProxySqlDataReader::SetService(MgFeatureService* service) { CHECKNULL(service, L"MgProxySqlDataReader.SetService"); if (m_service == NULL) { m_service = SAFE_ADDREF(service); } }
int MgdUpdateFeaturesCommand::ExecuteUpdate(MgResourceIdentifier* resource, CREFSTRING className, MgPropertyCollection* propertyValues, CREFSTRING filter, MgTransaction* trans) { int updated = 0; MG_FEATURE_SERVICE_TRY() CHECK_FEATURE_SOURCE_ARGUMENT(resource, L"MgdUpdateFeaturesCommand::ExecuteUpdate"); CHECKARGUMENTNULL(propertyValues, L"MgdUpdateFeaturesCommand::ExecuteUpdate"); if (className.empty()) throw new MgNullArgumentException(L"MgdUpdateFeaturesCommand::ExecuteUpdate", __LINE__, __WFILE__, NULL, L"", NULL); Ptr<MgdFeatureConnection> connWrap; FdoPtr<FdoIConnection> conn; FdoPtr<FdoITransaction> fdoTrans; Ptr<MgdTransaction> mgTrans = dynamic_cast<MgdTransaction*>(trans); if (NULL != mgTrans) { SAFE_ADDREF(mgTrans.p); Ptr<MgResourceIdentifier> origFeatureSource = mgTrans->GetFeatureSource(); //Check that the transaction originates from the same feature source if (origFeatureSource->ToString() != resource->ToString()) throw new MgInvalidArgumentException(L"MgdUpdateFeaturesCommand::ExecuteUpdate", __LINE__, __WFILE__, NULL, L"", NULL); connWrap = mgTrans->GetConnection(); //Connection is already open fdoTrans = mgTrans->GetFdoTransaction(); } else { connWrap = new MgdFeatureConnection(resource); } conn = connWrap->GetConnection(); FdoPtr<FdoIUpdate> update = (FdoIUpdate*)conn->CreateCommand(FdoCommandType_Update); update->SetFeatureClassName(className.c_str()); if (!filter.empty()) update->SetFilter(filter.c_str()); if (NULL != fdoTrans.p) update->SetTransaction(fdoTrans); FdoPtr<FdoPropertyValueCollection> propVals = update->GetPropertyValues(); for (INT32 i = 0; i < propertyValues->GetCount(); i++) { Ptr<MgProperty> mgp = propertyValues->GetItem(i); FdoPtr<FdoPropertyValue> pv = MgdFeatureUtil::MgPropertyToFdoProperty(mgp); propVals->Add(pv); } updated = update->Execute(); MG_FEATURE_SERVICE_CATCH_AND_THROW_WITH_FEATURE_SOURCE(L"MgdUpdateFeaturesCommand::ExecuteUpdate", resource) return updated; }
void MgProxyFeatureReader::SetService(MgFeatureService* service) { CHECKNULL(service, L"MgProxyFeatureReader.SetService"); if (m_service == NULL) { m_service = SAFE_ADDREF(service); SetServiceForFeatureProperties(service); } }
////////////////////////////////////////////////////////////// // Initialize class members which may not be set by the constructors void MgdMapPlot::Initialize() { Ptr<MgCoordinate> initCoord = new MgCoordinateXY(0, 0); m_center = initCoord; SAFE_ADDREF(m_center); m_scale = 0; m_extent = new MgEnvelope(initCoord, initCoord); m_bExpandToFit = true; m_layout = NULL; }
MgdMapPlot::MgdMapPlot(MgdMap* map, MgEnvelope* extent, bool expandToFit, MgdPlotSpecification* plotSpec, MgdLayout* layout) { if (map == NULL || extent == NULL || plotSpec == NULL) { throw new MgNullArgumentException(L"MgdMapPlot.MgdMapPlot", __LINE__, __WFILE__, NULL, L"", NULL); } Initialize(); m_map = SAFE_ADDREF(map); SAFE_RELEASE(m_extent); m_extent = SAFE_ADDREF(extent); m_bExpandToFit = expandToFit; m_plotSpec = SAFE_ADDREF(plotSpec); m_layout = SAFE_ADDREF(layout); m_plotInstruction = MgdMapPlotInstruction::UseOverriddenExtent; }
MgdMapPlot::MgdMapPlot(MgdMap* map, MgCoordinate* center, double scale, MgdPlotSpecification* plotSpec, MgdLayout* layout) { if (NULL == map || NULL == center || NULL == plotSpec) { throw new MgNullArgumentException(L"MgdMapPlot.MgdMapPlot", __LINE__, __WFILE__, NULL, L"", NULL); } Initialize(); m_map = SAFE_ADDREF(map); SAFE_RELEASE(m_center); m_center = SAFE_ADDREF(center); m_scale = scale; m_plotSpec = SAFE_ADDREF(plotSpec); m_layout = SAFE_ADDREF(layout); m_plotInstruction = MgdMapPlotInstruction::UseOverriddenCenterAndScale; }
/////////////////////////////////////////////////////////////////////////// // <summary> // Constructs a MgStreamData object with the given parameters/ // </summary> // // <param name = "pHandler"> // The ClientHandler object that is handling this stream. // </param> // // <param name = "handle"> // The ACE_HANDLE underlying the stream. // </param> // // <param name = "pStreamHelper"> // The MgStreamHelper object that handles data I/O for this stream. // </param> MgStreamData::MgStreamData( ACE_HANDLE handle, MgStreamHelper* pStreamHelper ) : m_Handle( handle ), m_pStreamHelper( SAFE_ADDREF(pStreamHelper) ), m_Version( 0 ), m_DataSize( 0 ), m_DataRead( 0 ), m_bError( false ) { ACE_ASSERT( handle != 0 ); ACE_ASSERT( pStreamHelper != NULL ); };
/////////////////////////////////////////////////////////////////////////////// /// \brief /// Return an existing MgFeatureSchemaCacheItem. /// MgFeatureSchemaCacheItem* MgFeatureServiceCacheEntry::GetFeatureSchemaCacheItem(CREFSTRING schemaName) { Ptr<MgFeatureSchemaCacheItem> item; MgFeatureSchemaCacheItems::iterator i = m_featureSchemaCacheItems.find(schemaName); if (m_featureSchemaCacheItems.end() != i) { item = SAFE_ADDREF(i->second); } return item.Detach(); }
/////////////////////////////////////////////////////////////////////////////// /// \brief /// Return an existing MgFeatureSchemaCacheItem or a newly created one /// if it does not exist. /// MgFeatureSchemaCacheItem* MgFeatureServiceCacheEntry::SetFeatureSchemaCacheItem(CREFSTRING schemaName) { Ptr<MgFeatureSchemaCacheItem> item = GetFeatureSchemaCacheItem(schemaName); if (NULL == item.p) { item = new MgFeatureSchemaCacheItem(); m_featureSchemaCacheItems.insert(MgFeatureSchemaCacheItems::value_type( schemaName, SAFE_ADDREF(item.p))); } return item.Detach(); }
HRESULT CSWPosImage::SetImage(CSWImage* pImage) { if (NULL != pImage) { SAFE_RELEASE(m_pImage); m_pImage = pImage; SAFE_ADDREF(m_pImage); return S_OK; } return E_INVALIDARG; }
// Get the property for the specified index MgProperty* MgProxyFeatureReader::GetProperty(INT32 index) { CHECKNULL(m_set, L"MgProxyFeatureReader.GetProperty"); CHECK_FEATURESET_COUNT(m_set, L"MgProxyFeatureReader.GetProperty"); Ptr<MgPropertyCollection> ptrCol = m_set->GetFeatureAt(m_currRecord-1); CHECKNULL(ptrCol, L"MgProxyFeatureReader.GetProperty"); Ptr<MgProperty> ptrProp = ptrCol->GetItem(index); CHECKNULL(ptrProp, L"MgProxyFeatureReader.GetProperty"); return SAFE_ADDREF(ptrProp.p); }
MgByteReader* MgResourceDefinitionManager::GetResource( MgResourceIdentifier* resource, const MgDataBindingInfo* dataBindingInfo) { assert(NULL != resource); Ptr<MgByteReader> byteReader; MG_RESOURCE_SERVICE_TRY() // Get the resource. XmlDocument xmlDoc = GetDocument(*resource); string document; xmlDoc.getContent(document); // Bind the data if required. if (NULL != dataBindingInfo) { // Substitute all the tags if necessary. XmlValue tagValue; if (xmlDoc.getMetaData(MgResourceInfo::sm_metadataUri, MgResourceInfo::sm_metadataNames[MgResourceInfo::Tags], tagValue)) { STRING resourceTags; MgUtil::MultiByteToWideChar(tagValue.asString(), resourceTags); // If there is no resource tag, then just do the substitution for // the login username and password. MgTagManager tagManager(resourceTags); tagManager.SubstituteTags(*dataBindingInfo, document); } } // Create a byte reader. Ptr<MgByteSource> byteSource = new MgByteSource( (unsigned char*)document.c_str(), (INT32)document.length()); byteSource->SetMimeType(MgMimeType::Xml); byteReader = byteSource->GetReader(); MG_RESOURCE_CONTAINER_CATCH_AND_THROW(L"MgResourceDefinitionManager.GetResource") return SAFE_ADDREF((MgByteReader*)byteReader); }
void MgFeatureNumericFunctions::Initialize(MgReader* reader, FdoFunction* customFunction, CREFSTRING propertyAlias) { CHECKNULL((MgReader*)reader, L"MgFeatureNumericFunctions.Initialize"); CHECKNULL((FdoFunction*)customFunction, L"MgFeatureNumericFunctions.Initialize"); if(1 == reader->GetPropertyCount()) { m_type = MgServerFeatureUtil::GetPropertyDefinition(reader, m_propertyName); } else { // Only get the property needed FdoPtr<FdoExpressionCollection> exprCol = customFunction->GetArguments(); FdoInt32 cnt = exprCol->GetCount(); FdoPtr<FdoExpression> expr; if(cnt == 1) { expr = exprCol->GetItem(0); FdoIdentifier* propName = dynamic_cast<FdoIdentifier*>(expr.p); CHECKNULL(propName, L"MgFeatureNumericFunctions.Initialize"); m_propertyName = propName->GetName(); m_type = reader->GetPropertyType(m_propertyName); } else { // Throw original exception m_type = MgServerFeatureUtil::GetPropertyDefinition(reader, m_propertyName); } } // TODO: Should we really check this, may be we can ignore ?? // because we can only come to here if property type is numeric this->CheckSupportedPropertyType(); // We must have an property alias // Though we can name a property with same name as function expression // But Fdo forces to have an alias. Therefore we implement this restriction. if (propertyAlias.empty()) { STRING message = MgServerFeatureUtil::GetMessage(L"MgMissingPropertyAlias"); MgStringCollection arguments; arguments.Add(message); throw new MgFeatureServiceException(L"MgFeatureDistribution.Initialize", __LINE__, __WFILE__, &arguments, L"", NULL); } m_reader = SAFE_ADDREF(reader); m_customFunction = FDO_SAFE_ADDREF(customFunction); m_propertyAlias = propertyAlias; }