Ejemplo n.º 1
0
STDMETHODIMP CTRiASHPDBEngine::EnumDataBaseTypes (IUnknown **ppIEnum)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState())
	CHECKOUTPOINTER(ppIEnum);	

CComObject<CEnumString> *pIEnum = NULL;

	ATLTRY(pIEnum = new CComObject<CEnumString>());
	if (NULL == pIEnum) return E_OUTOFMEMORY;

// die Funktion Init des EnumTemplates erwartet die Adressen des ersten und 
// letzten+1 Elementes eines Vektors
LPOLESTR *ppStringsStart = (LPOLESTR *)&s_poleTypesNormal[0];
LPOLESTR *ppStringsEnd = (LPOLESTR *)&s_poleTypesNormal[_countof(s_poleTypesNormal)];

HRESULT hr = pIEnum -> Init (ppStringsStart, ppStringsEnd, static_cast<ITRiASDBEngine *>(this), AtlFlagCopy);

	if (SUCCEEDED(hr))
		hr = pIEnum -> QueryInterface(IID_IEnumString, (LPVOID *)ppIEnum);

	if (FAILED(hr))		// bei Fehler alles freigeben
		delete pIEnum;

	return hr;
}
Ejemplo n.º 2
0
STDMETHODIMP CTRiASOGCDBEngine::get_Description (BSTR * pVal)
{
#if defined(_MFC_VER)
	AFX_MANAGE_STATE(AfxGetStaticModuleState())
#endif // defined(_MFC_VER)

	CHECKOUTPOINTER(pVal);	

// Wert aus der Registry lesen
CRegKey regKey;
char cbBuffer[_MAX_PATH];
DWORD dwLen = sizeof(cbBuffer);

	if (ERROR_SUCCESS != regKey.Open(HKEY_CLASSES_ROOT, "TRiASDB.TRiASOGC.DBEngine.1", KEY_READ) || 
		ERROR_SUCCESS != regKey.QueryValue(cbBuffer, NULL, &dwLen))
	{
		return E_UNEXPECTED;
	}

CComBSTR bstr (cbBuffer);

	if (!bstr)
		return E_OUTOFMEMORY;

	*pVal = bstr.Detach();
	return S_OK;
}
Ejemplo n.º 3
0
///////////////////////////////////////////////////////////////////////////////
// TRiASCS Objekt aus Wkt erzeugen
STDMETHODIMP CTRiASCSWktService::CreateFromWkt(WKTFORMAT rgFormat, BSTR bstrWktCS, ITRiASCS **ppICS)
{
    CHECKOUTPOINTER(ppICS);
    CHECKINPOINTER(bstrWktCS);

    return S_OK;
}
Ejemplo n.º 4
0
IMPLEMENT_DEBUG_FUNCENTRY_4(CGDODatabase,get_ObjectsDef,VARIANT, vIndex, VARIANT_BOOL, fCreate, BSTR, Type, ITRiASObjects**, ppIObjectsDef) 
{
	CHECKOUTPOINTER(ppIObjectsDef);
	COM_TRY {
		CHECK_INITIALIZED();

	WTRiASObjects	pTRiASObjects;
	CComVariant	vItem;

		RETURN_FAILED_HRESULT(EnsureObjectsColl());
	
	HRESULT hr = m_pGDOObjectsCollection -> Item (vIndex, CLEARED(vItem));

		if (SUCCEEDED(hr)) 
			pTRiASObjects = V_DISPATCH(&vItem);
		else if (TRIASDB_E_UNKNOWN_OBJECTS == hr && fCreate) {
		WTRiASObjectsCollection	pTRiASObjectsCollection;
		
			ERROR_FAILED_HRESULT(m_pGDOObjectsCollection -> QueryInterface (pTRiASObjectsCollection.ppi()), E_FAIL);
			ERROR_FAILED_HRESULT(pTRiASObjectsCollection -> Add (V_BSTR(&vIndex), Type, pTRiASObjects.ppi()), E_FAIL);
		} else 
			return hr;

		*ppIObjectsDef = pTRiASObjects.detach();
	} COM_CATCH;
	return S_OK;
}
Ejemplo n.º 5
0
STDMETHODIMP CFastdbGeoFeatures::OnChanging(CHANGEDFEATURES rgWhat, VARIANT vNewValue, VARIANT_BOOL *pDisAllow)
{
	CHECKOUTPOINTER(pDisAllow);

	*pDisAllow = VARIANT_FALSE;		// immer einverstanden sein
	return S_OK;
}
Ejemplo n.º 6
0
/////////////////////////////////////////////////////////////////////////////
// ITRiASFeatureCallback
STDMETHODIMP CFastdbFeature::get_DefaultType (BSTR *pbstrType)
{
	CHECKOUTPOINTER(pbstrType);

CIID Guid (GetObjectCLSID());
CComBSTR bstrType (Guid.ProgID().c_str());

	*pbstrType = bstrType.Detach();
	return S_OK;
}
Ejemplo n.º 7
0
STDMETHODIMP CTRiASMIObjectsCollection::get_DefaultType (BSTR *pbstrType)
{
	CHECKOUTPOINTER(pbstrType);

CIID Guid (CLSID_TRiASMIObjects);		// DefaultType der _Elemente_ (hier: Objektklasse)!
CComBSTR bstrType (Guid.ProgID().c_str());

	*pbstrType = bstrType.Detach();
	return S_OK;
}
Ejemplo n.º 8
0
STDMETHODIMP CFastdbGeoFeatures::get_DefaultType (BSTR *pbstrType)
{
	CHECKOUTPOINTER(pbstrType);

CIID Guid (CLSID_TRiASSimpleGeoFeature);		// DefaultType der _Elemente_ !
CComBSTR bstrType (Guid.ProgID().c_str());

	*pbstrType = bstrType.Detach();
	return S_OK;
}
Ejemplo n.º 9
0
IMPLEMENT_DEBUG_FUNCENTRY_1(CGDODatabase,get_ObjectsDefs,/*[out, retval]*/ ITRiASObjectsCollection**, ppVal) {
	CHECKOUTPOINTER(ppVal);
	COM_TRY {
		ERROR_EXPR_FALSE( S_OK == IsInitialized(), DBE_E_DATABASE_NOT_OPENED );
		RETURN_FAILED_HRESULT( EnsureObjectsColl() );
		WTRiASObjectsCollection	pTRiASObjectsCollection(m_pGDOObjectsCollection);
		*ppVal = pTRiASObjectsCollection.Detach();
	} COM_CATCH;
	return S_OK;
}
Ejemplo n.º 10
0
STDMETHODIMP CTRiASHPGeoFeatures::OnChanging(CHANGEDFEATURES rgWhat, VARIANT vNewValue, VARIANT_BOOL *pDisAllow)
{
	CHECKOUTPOINTER(pDisAllow);

#if defined(_READWRITE)
	*pDisAllow = VARIANT_FALSE;		// immer einverstanden sein
	return S_OK;
#else
	*pDisAllow = VARIANT_TRUE;		// nie einverstanden sein
	return TRIASDB_E_OBJECTSNOTUPDATABLE;
#endif
}
Ejemplo n.º 11
0
STDMETHODIMP CTRiASHPDBEngine::get_Description (BSTR * pVal)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState())
	CHECKOUTPOINTER(pVal);	

CComBSTR bstr;

	if (!bstr.LoadString (IDS_DBENGINE_DESC))
		return E_OUTOFMEMORY;

	*pVal = bstr.Detach();
	return S_OK;
}
Ejemplo n.º 12
0
// eine neue Objekteigenschaft soll erzeugt werden
STDMETHODIMP CFastdbFeatures::OnCreate (VARIANT Name, BSTR Type, FEATURETYPE rgType, ITRiASFeature **ppIFeat)
{
	CHECKOUTPOINTER(ppIFeat);

	USES_CONVERSION;
	COM_TRY {
	// jetzt wirklich erzeugen
	CIID ClsId (Type, CIID::INITCIID_InitFromProgId);

		if (!ClsId)	ClsId = CLSID_FastdbFeature;	// default ClsId

	WTRiASFeatures BaseFeats;
	WDispatch Parent;

		THROW_FAILED_HRESULT(m_BaseUnk -> QueryInterface (BaseFeats.ppi()));
		THROW_FAILED_HRESULT(BaseFeats -> get_Parent (Parent.ppi()));

	// Parent muß hier Objektklasse sein
	WTRiASObjects Objs;

		THROW_FAILED_HRESULT(Parent -> QueryInterface (Objs.ppi()));

	// neuen Satz erzeugen und zu der Objektklasse hinzufügen
	LONG lCursor (GetPropertyFrom (Objs, g_cbObjectsCursor, 0L));

		_ASSERTE(0 != lCursor);

	dbDatabase *pdb = GetRelatedDatabase(GetUnknown());
	dbCursor<CDBClass> cursor (pdb);
	CDBClass *pClass = cursor.at (dbReference<CDBClass>(oid_t(lCursor)));

		if (NULL == pClass || cursor.isEmpty())
			THROW_FAILED_HRESULT(FASTDB_E_OBJECTS_BADREFERENCE);

	CComVariant vVal;
	CDBFeatureDesc FDesc;

		THROW_FAILED_HRESULT(vVal.ChangeType (VT_BSTR, &Name));
	
		FDesc.m_pName = OLE2A(V_BSTR(&vVal));
		FDesc.m_rgType = rgType;
		FDesc.objclass = cursor.currentId();
	
	dbCursor<CDBFeatureDesc> featuredesc (GetRelatedDatabase(GetUnknown()));

		featuredesc.at (pdb -> insert (FDesc));
		THROW_FAILED_HRESULT(SetupFeature (ClsId, BaseFeats, featuredesc, Parent, ppIFeat));

	} COM_CATCH;
	return S_OK;
}
Ejemplo n.º 13
0
///////////////////////////////////////////////////////////////////////////////
// ITRiASDBEngine
STDMETHODIMP CTRiASHPDBEngine::get_Version (BSTR *pVal)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState())
	CHECKOUTPOINTER(pVal);	

CString strVersion;

	strVersion.Format (_T("%d.%02d.%03d"), TRIASHP_VERSION, TRIASHP_RELEASE, TRIASHP_BUILD);

CComBSTR bstrVersion (strVersion);

	*pVal = bstrVersion.Detach();
	return S_OK;
}
Ejemplo n.º 14
0
STDMETHODIMP CTDBPGISDBEngine::get_Description (BSTR * pVal)
{
#if defined(_MFC_VER)
	AFX_MANAGE_STATE(AfxGetStaticModuleState())
#endif // defined(_MFC_VER)

	CHECKOUTPOINTER(pVal);	

CComBSTR bstr;

	if (!bstr.LoadString (IDS_DBENGINE_DESC))
		return E_OUTOFMEMORY;

	*pVal = bstr.Detach();
	return S_OK;
}
Ejemplo n.º 15
0
STDMETHODIMP CTRiASOGCDBEngine::EnumDataBaseTypes (IUnknown **ppIEnum)
{
#if defined(_MFC_VER)
	AFX_MANAGE_STATE(AfxGetStaticModuleState())
#endif // defined(_MFC_VER)

	CHECKOUTPOINTER(ppIEnum);	

// alle registrierten Datenquellentypen aus Regsitry lesen
CRegKey regEnum;

	if (ERROR_SUCCESS != regEnum.Open(HKEY_CLASSES_ROOT, "TRiASDB.TRiASOGC.DBEngine.1", KEY_READ) ||
		ERROR_SUCCESS != regEnum.Open(regEnum, "TRiASDB", KEY_READ))
	{
		return E_UNEXPECTED;
	}

HRESULT hr = S_OK;

	COM_TRY {
	vector<CComBSTR> vecKeys;
	DWORD dwIndex = 0;
	char cbName[_MAX_PATH];
	DWORD dwSizeName = sizeof(cbName);

		while (ERROR_SUCCESS == RegEnumKey(regEnum, dwIndex++, cbName, dwSizeName)) 
			vecKeys.push_back(CComBSTR(cbName));

	// gefundene Datenquellentypen in Enumerator übernehmen
	CComObject<CEnumString> *pIEnum = new CComObject<CEnumString>();

	// die Funktion Init des EnumTemplates erwartet die Adressen des ersten und 
	// letzten+1 Elementes eines Vektors
	LPOLESTR *poleStart = (LPOLESTR *)vecKeys.begin();
	LPOLESTR *poleEnd = (LPOLESTR *)vecKeys.end();

		hr = pIEnum -> Init (poleStart, poleEnd, static_cast<ITRiASDBEngine *>(this), AtlFlagCopy);
		if (SUCCEEDED(hr))
			hr = pIEnum -> QueryInterface(IID_IEnumString, (LPVOID *)ppIEnum);

		if (FAILED(hr))		// bei Fehler alles freigeben
			delete pIEnum;

	} COM_CATCH;
	return hr;
}
Ejemplo n.º 16
0
///////////////////////////////////////////////////////////////////////////////
// aus TRiASCS Wkt erzeugen
STDMETHODIMP CTRiASCSWktService::ExportAsWkt(WKTFORMAT rgFormat, ITRiASCS *pCS, BSTR *pbstrWktCS)
{
    CHECKOUTPOINTER(pbstrWktCS);
    CHECKINPOINTER(pCS);

    if (WKTFORMAT_OgcWkt != rgFormat)
        return E_INVALIDARG;

    COM_TRY {
        // ist's einprojektives System
        CComBSTR bstrWkt;
        CComBSTR bstr;
        TRIASCSTYPE rgType;
        WTRiASCSPCS PCS;

        THROW_FAILED_HRESULT(pCS -> get_CoordSystemType(&rgType));
        if (tcsCS_Projected == rgType) {
            bstrWkt.Append(L"PROJCS[\"");

            // Namen der Projektion ausgeben
            THROW_FAILED_HRESULT(RetrieveProjectedName (pCS, CLEARED(&bstr)));
            bstrWkt.Append(bstr);
        }

        // Datumsbeschreibung ausgeben
        WTRiASCSGCS GCS;

        THROW_FAILED_HRESULT(pCS -> get_GeographicCS(GCS.ppi()));
        THROW_FAILED_HRESULT(ExportGeographicSystem(GCS, CLEARED(&bstr)));
        bstrWkt.Append(bstr);

        // ggf. Projektionsparameter ausgeben
        if (tcsCS_Projected == rgType) {
            _ASSERTE(PCS.IsValid());

            THROW_FAILED_HRESULT(ExportProjectionParams(PCS, CLEARED(&bstr)));
            bstrWkt.Append(bstr);
            bstrWkt.Append(L"]");
        }

        // Resultat liefern
        *pbstrWktCS = bstrWkt.Detach();

    } COM_CATCH;
    return S_OK;
}
Ejemplo n.º 17
0
///////////////////////////////////////////////////////////////////////////////
// ITRiASDBEngine
STDMETHODIMP CTRiASOGCDBEngine::get_Version (BSTR *pVal)
{
#if defined(_MFC_VER)
	AFX_MANAGE_STATE(AfxGetStaticModuleState())
#endif // defined(_MFC_VER)

	CHECKOUTPOINTER(pVal);	

CString strVersion;

	strVersion.Format (_T("%s.%s.%s"), TRIASOGC_VERSION, TRIASOGC_RELEASE, TRIASOGC_BUILD);

CComBSTR bstrVersion (strVersion);

	*pVal = bstrVersion.Detach();
	return S_OK;
}
Ejemplo n.º 18
0
///////////////////////////////////////////////////////////////////////////////
// Erzeugen einer neuen Objektklasse
STDMETHODIMP CTRiASMIObjectsCollection::OnCreate (
	VARIANT NameOrHandle, BSTR Type, OBJECTSCOLLECTIONTYPE rgType, ITRiASObjects **ppIObjs)
{
	CHECKOUTPOINTER(ppIObjs);

#if defined(_READWRITE)
// jetzt wirklich erzeugen
CIID ClsId (Type, CIID::INITCIID_InitFromProgId);

	if (!ClsId)	ClsId = CLSID_TRiASHPObjects;	// default ClsId

	RETURN_FAILED_HRESULT(CreateObject (NameOrHandle, rgType, &ClsId, ppIObjs));
	return S_OK;
#else
	return TRIASDB_E_DATABASENOTUPDATABLE;
#endif // defined(_READWRITE)
}