// datastore2.idl : IDL source for datastore2.dll
//

// This file will be processed by the MIDL tool to
// produce the type library (datastore2.tlb) and marshalling code.

import "oaidl.idl";

   interface IDataStore2;
   interface IDataStoreContainer;
   interface IDataStoreObject;
   interface IDataStoreProperty;

   //////////////////////////////////////////////////////////////////////////
   //
   // Name:    IDataStoreProperty
   //
   // What:    Represents a single property of an abstract data store object. 
   //
   // Purpose: Enable an SDO client to enumerate all the properties of an
   //          object.
   //
   //////////////////////////////////////////////////////////////////////////
   [
      object,
      uuid(6BC096C9-0CE6-11D1-BAAE-00C04FC2E20D),
      dual
   ]
   interface IDataStoreProperty : IDispatch
   {
      [propget, id(1)] 
      HRESULT Name([out, retval] BSTR* pVal);

      [propget, id(2)] 
      HRESULT Value([out, retval] VARIANT* pVal);

      [propget, id(3)] 
      HRESULT ValueEx([out, retval] VARIANT* pVal);

      [propget, id(4)] 
      HRESULT Owner([out, retval] IDataStoreObject** pVal);
   };

   //////////////////////////////////////////////////////////////////////////
   //
   // Name:   IDataStoreObject
   //
   // What:   Interface exported by all abstract data store objects. 
   //
   // Purpose: Enable an SDO client to treat the underlying data store
   //         as an abstract entity
   //
   //////////////////////////////////////////////////////////////////////////
   [
      object,
      uuid(6BC096C0-0CE6-11D1-BAAE-00C04FC2E20D),
      dual,
      pointer_default(unique)
   ]
   interface IDataStoreObject : IDispatch
   {
      // Retrieves the object's name (unique within collection?)
      [propget, id(1)] 
      HRESULT Name([out, retval] BSTR* pVal);

      // Retrieves object's class (table) 
      [propget, id(2)] 
      HRESULT Class([out, retval] BSTR* pVal);

      // Retrieves obect's unique identifier.
      [propget, id(3)] 
      HRESULT GUID([out, retval] BSTR* pVal);

      // Retrieves the object's container
      [propget, id(4)] 
      HRESULT Container([out, retval] IDataStoreContainer** pVal);      

      // Multi-valued items are retrieved as safearrays
      [id(5)] 
      HRESULT GetValue([in] BSTR bstrName, [out, retval] VARIANT* pVal);

      // All items are retrieved as safearrays
      [id(6)] 
      HRESULT GetValueEx([in] BSTR bstrName, [out, retval] VARIANT* pVal);

      // Multi-valued items are put as safearrays
      [id(7)] 
      HRESULT PutValue([in] BSTR bstrName, [in] VARIANT* pVal);

      // Update the underlying data store with the current state of
      // the data store object's interanl buffer
      [id(8)] 
      HRESULT Update();

      // Restore the state of the data store object to its last
      // persisted state.
      [id(9)] 
      HRESULT Restore();

      // The number of properties associated with the object.
      [propget, id(10)]
      HRESULT Count([out, retval] long* pVal);

      // Retrieves the IDataStoreProperty representation of a property.
      [id(DISPID_VALUE)]
      HRESULT Item([in] BSTR bstrName,
                   [out, retval] IDataStoreProperty** pVal);

      // Returns an IEnumVARIANT that enumerates all the properties.
      [propget, restricted, id(DISPID_NEWENUM)]
      HRESULT _NewEnum([out, retval] IUnknown** pVal);
   };

   //////////////////////////////////////////////////////////////////////////
   //
   // Name:   IDataStoreContainer
   //
   // What:   Interface exported by all abstract data store containers. 
   //
   // Purpose: Enable an SDO collection to treat the underlying data store
   //         collection (container) as an abstract entity
   //
   //////////////////////////////////////////////////////////////////////////
   [
      uuid(6BC096C1-0CE6-11D1-BAAE-00C04FC2E20D),
      dual,
      pointer_default(unique)
   ]
   interface IDataStoreContainer : IDispatch
   {
      [propget, restricted, id(DISPID_NEWENUM)] 
      HRESULT _NewEnum([out, retval] IUnknown** pVal);
      
      // Retrieves the specified item
      [id(DISPID_VALUE)]           
      HRESULT Item([in] BSTR bstrName,
                   [out, retval] IDataStoreObject** ppObject);

      [propget, id(1)]           
      HRESULT Count([out, retval] long *pVal);

      // Create an object of the "class" type supported by this container
      [id(2)]                     
      HRESULT Create([in] BSTR bstrClass,
                     [in] BSTR bstrName,
                     [out, retval]IDataStoreObject** ppObject);

      // Add an object of "class" type. If bstrNewName is non-null, the 
      // object is renamed.
      [id(3)]                    
      HRESULT MoveHere([in] IDataStoreObject* pObject, [in] BSTR bstrNewName);

      // Removes the specified item
      [id(4)]                     
      HRESULT Remove([in] BSTR bstrClass, [in] BSTR bstrName);
   };


   //////////////////////////////////////////////////////////////////////////
   //
   // Name:   IDataStore
   //
   // What:   Interface on top of an abstract data store. 
   //
   // Purpose: Enable an SDO client to treat the underlying data store
   //         as an abstract entity
   //
   //////////////////////////////////////////////////////////////////////////
   [
      object,
      uuid(6BC096C2-0CE6-11D1-BAAE-00C04FC2E20D),
      dual,
      pointer_default(unique)
   ]
   interface IDataStore2 : IDispatch
   {
      // Get the root object.
      [propget]
      HRESULT Root([out, retval] IDataStoreObject** ppObject);

      // Initialize the data store.
      HRESULT Initialize(
                  [in] BSTR bstrDSName,   // Full UNC name of the data source
                  [in] BSTR bstrUserName, // Can be NULL
                  [in] BSTR bstrPassword  // Can be NULL
                  );

      // Retrieve a specific object from the datastore.
      // The path is implementation specific.
      HRESULT OpenObject(
                  [in] BSTR bstrPath,
                  [out, retval] IDataStoreObject** ppObject
                  );

      // Shutdown the data store
      HRESULT Shutdown();
   };

   [
      object,
      uuid(F42CFA19-EA06-4EB6-9891-D583F0CE46FC),
      oleautomation
   ]
   interface IAttributeDictionary : IUnknown
   {
      HRESULT GetDictionary(
                  [in] BSTR bstrPath,
                  [out, retval] VARIANT* pVal
                  );
   };

   //////////////////////////////////////////////////////////////////////////
   //
   // Name:   IIASNetshJetHelper
   //
   // What:   Interface used by aaaamon.dll (netshell aaaa) to work with Jet
   //
   // Purpose: That object should always be in a 32bits process to access 
   //          The Jet provider properly
   //
   //////////////////////////////////////////////////////////////////////////
    [
        object,
        uuid(20290BE7-A2AE-42C2-8883-FA09973ED3A5),
        oleautomation,
    ]
    interface IIASNetshJetHelper : IUnknown
    {
        // Open the Jet 4 DB
        HRESULT OpenJetDatabase(
                                 [in] BSTR  Path,
                                 [in] VARIANT_BOOL ReadOnly
                               );

        // Execute a SQL function and return the result (LONG)
        HRESULT ExecuteSQLFunction(
                                    [in] BSTR Command, 
                                    [out, retval] LONG* Result
                                  );
        
        // Execute a SQL Command.
        HRESULT ExecuteSQLCommand(
                                    [in] BSTR Command
                                 );

        // Create an empty Jet 4 DB
        HRESULT CreateJetDatabase(
                                    [in] BSTR Path
                                 );
        
        // Close the currently opened DB
        HRESULT CloseJetDatabase();
        
		// Upgrade the DB
        HRESULT UpgradeDatabase();
    };
