text: //=---------------------------------------------------------------------=
  //
  // This file was GENERATED for the AAF SDK
  //
  // $Id$ $Name$
  //
  // The contents of this file are subject to the AAF SDK Public Source
  // License Agreement Version 2.0 (the "License"); You may not use this
  // file except in compliance with the License.  The License is available
  // in AAFSDKPSL.TXT, or you may obtain a copy of the License from the
  // Advanced Media Workflow Association, Inc., or its successor.
  //
  // Software distributed under the License is distributed on an "AS IS"
  // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.  See
  // the License for the specific language governing rights and limitations
  // under the License.  Refer to Section 3.3 of the License for proper use
  // of this Exhibit.
  //
  // WARNING:  Please contact the Advanced Media Workflow Association,
  // Inc., for more information about any additional licenses to
  // intellectual property covering the AAF Standard that may be required
  // to create and distribute AAF compliant products.
  // (http://www.amwa.tv/policies).
  //
  // Copyright Notices:
  // The Original Code of this file is Copyright 1998-2012, licensor of the
  // Advanced Media Workflow Association.  All rights reserved.
  //
  // The Initial Developer of the Original Code of this file and the
  // licensor of the Advanced Media Workflow Association is
  // Avid Technology.
  // All rights reserved.
  //
  //=---------------------------------------------------------------------=
  
  
  
  #include "CAAFDescriptiveMarker.h"
  #include "ImplAAFDescriptiveMarker.h"
  #include "AAFResult.h"
  #include "CAAFEnumValidation.h"
  
  #include "OMAssertions.h"
  #include "OMExceptions.h"
  
  #include <assert.h>
  #include <string.h>
  
  
  
  
  #include "CAAFDescriptiveFramework.h"
  #include "ImplAAFDescriptiveFramework.h"
  
  
  // CLSID for AAFDescriptiveMarker 
  // {d035e5fe-0bf1-4dc5-ae6b-2c37f43a07a6}
  EXTERN_C const CLSID CLSID_AAFDescriptiveMarker = { 0xd035e5fe, 0x0bf1, 0x4dc5, { 0xae, 0x6b, 0x2c, 0x37, 0xf4, 0x3a, 0x07, 0xa6 } };
  
  
  
  
  
  
  CAAFDescriptiveMarker::CAAFDescriptiveMarker (IUnknown * pControllingUnknown, aafBool doInit)
    : CAAFCommentMarker (pControllingUnknown, kAAFFalse)
  {
    if (doInit)
      {
        ImplAAFDescriptiveMarker * newRep;
        newRep = new ImplAAFDescriptiveMarker;
        assert (newRep);
        InitRep (newRep);
      }
  }
  
  
  CAAFDescriptiveMarker::~CAAFDescriptiveMarker ()
  {
  }
  
  
  
  HRESULT STDMETHODCALLTYPE
      CAAFDescriptiveMarker::Initialize ()
  {
    ImplAAFDescriptiveMarker * ptr;
    ImplAAFRoot * pO;
    pO = GetRepObject ();
    assert (pO);
    ptr = static_cast<ImplAAFDescriptiveMarker*> (pO);
    assert (ptr);
    HRESULT hr;
  
    try
      {
        hr = ptr->Initialize();
      }
    catch (OMException& e)
      {
        // OMExceptions should be handled by the impl code. However, if an
        // unhandled OMException occurs, control reaches here. We must not
        // allow the unhandled exception to reach the client code, so we
        // turn it into a failure status code.
        //
        // If the OMException contains an HRESULT, it is returned to the
        // client, if not, AAFRESULT_UHANDLED_EXCEPTION is returned.
        //
        hr = OMExceptionToResult(e, AAFRESULT_UNHANDLED_EXCEPTION);
      }
    catch (OMAssertionViolation &)
      {
        // Control reaches here if there is a programming error in the
        // impl code that was detected by an assertion violation.
        // We must not allow the assertion to reach the client code so
        // here we turn it into a failure status code.
        //
        hr = AAFRESULT_ASSERTION_VIOLATION;
      }
    catch (...)
      {
        // We CANNOT throw an exception out of a COM interface method!
        // Return a reasonable exception code.
        //
        hr = AAFRESULT_UNEXPECTED_EXCEPTION;
      }
  
    return hr;
  }
  
  
  
  HRESULT STDMETHODCALLTYPE
      CAAFDescriptiveMarker::SetDescribedSlotIDs (aafUInt32  numberElements,
          aafUInt32*  pDescribedSlotIDs)
  {
    HRESULT hr;
  
    ImplAAFDescriptiveMarker * ptr;
    ImplAAFRoot * pO;
    pO = GetRepObject ();
    assert (pO);
    ptr = static_cast<ImplAAFDescriptiveMarker*> (pO);
    assert (ptr);
  
  
    try
      {
        hr = ptr->SetDescribedSlotIDs
         (numberElements,
          pDescribedSlotIDs);
      }
    catch (OMException& e)
      {
        // OMExceptions should be handled by the impl code. However, if an
        // unhandled OMException occurs, control reaches here. We must not
        // allow the unhandled exception to reach the client code, so we
        // turn it into a failure status code.
        //
        // If the OMException contains an HRESULT, it is returned to the
        // client, if not, AAFRESULT_UHANDLED_EXCEPTION is returned.
        //
        hr = OMExceptionToResult(e, AAFRESULT_UNHANDLED_EXCEPTION);
      }
    catch (OMAssertionViolation &)
      {
        // Control reaches here if there is a programming error in the
        // impl code that was detected by an assertion violation.
        // We must not allow the assertion to reach the client code so
        // here we turn it into a failure status code.
        //
        hr = AAFRESULT_ASSERTION_VIOLATION;
      }
    catch (...)
      {
        // We CANNOT throw an exception out of a COM interface method!
        // Return a reasonable exception code.
        //
        hr = AAFRESULT_UNEXPECTED_EXCEPTION;
      }
  
    return hr;
  }
  
  
  
  HRESULT STDMETHODCALLTYPE
      CAAFDescriptiveMarker::GetDescribedSlotIDs (aafUInt32  numberElements,
          aafUInt32*  pDescribedSlotIDs)
  {
    HRESULT hr;
  
    ImplAAFDescriptiveMarker * ptr;
    ImplAAFRoot * pO;
    pO = GetRepObject ();
    assert (pO);
    ptr = static_cast<ImplAAFDescriptiveMarker*> (pO);
    assert (ptr);
  
  
    try
      {
        hr = ptr->GetDescribedSlotIDs
         (numberElements,
          pDescribedSlotIDs);
      }
    catch (OMException& e)
      {
        // OMExceptions should be handled by the impl code. However, if an
        // unhandled OMException occurs, control reaches here. We must not
        // allow the unhandled exception to reach the client code, so we
        // turn it into a failure status code.
        //
        // If the OMException contains an HRESULT, it is returned to the
        // client, if not, AAFRESULT_UHANDLED_EXCEPTION is returned.
        //
        hr = OMExceptionToResult(e, AAFRESULT_UNHANDLED_EXCEPTION);
      }
    catch (OMAssertionViolation &)
      {
        // Control reaches here if there is a programming error in the
        // impl code that was detected by an assertion violation.
        // We must not allow the assertion to reach the client code so
        // here we turn it into a failure status code.
        //
        hr = AAFRESULT_ASSERTION_VIOLATION;
      }
    catch (...)
      {
        // We CANNOT throw an exception out of a COM interface method!
        // Return a reasonable exception code.
        //
        hr = AAFRESULT_UNEXPECTED_EXCEPTION;
      }
  
    return hr;
  }
  
  
  HRESULT STDMETHODCALLTYPE
      CAAFDescriptiveMarker::GetDescribedSlotIDsSize (aafUInt32 *  numberElements)
  {
    HRESULT hr;
  
    ImplAAFDescriptiveMarker * ptr;
    ImplAAFRoot * pO;
    pO = GetRepObject ();
    assert (pO);
    ptr = static_cast<ImplAAFDescriptiveMarker*> (pO);
    assert (ptr);
  
  
    try
      {
        hr = ptr->GetDescribedSlotIDsSize
         (numberElements);
      }
    catch (OMException& e)
      {
        // OMExceptions should be handled by the impl code. However, if an
        // unhandled OMException occurs, control reaches here. We must not
        // allow the unhandled exception to reach the client code, so we
        // turn it into a failure status code.
        //
        // If the OMException contains an HRESULT, it is returned to the
        // client, if not, AAFRESULT_UHANDLED_EXCEPTION is returned.
        //
        hr = OMExceptionToResult(e, AAFRESULT_UNHANDLED_EXCEPTION);
      }
    catch (OMAssertionViolation &)
      {
        // Control reaches here if there is a programming error in the
        // impl code that was detected by an assertion violation.
        // We must not allow the assertion to reach the client code so
        // here we turn it into a failure status code.
        //
        hr = AAFRESULT_ASSERTION_VIOLATION;
      }
    catch (...)
      {
        // We CANNOT throw an exception out of a COM interface method!
        // Return a reasonable exception code.
        //
        hr = AAFRESULT_UNEXPECTED_EXCEPTION;
      }
  
    return hr;
  }
  
  
  HRESULT STDMETHODCALLTYPE
      CAAFDescriptiveMarker::SetDescriptiveFramework (IAAFDescriptiveFramework * pDescriptiveFramework)
  {
    HRESULT hr;
  
    ImplAAFDescriptiveMarker * ptr;
    ImplAAFRoot * pO;
    pO = GetRepObject ();
    assert (pO);
    ptr = static_cast<ImplAAFDescriptiveMarker*> (pO);
    assert (ptr);
  
    //
    // set up for pDescriptiveFramework
    //
    ImplAAFDescriptiveFramework * internalpDescriptiveFramework = NULL;
    if (pDescriptiveFramework)
      {
        HRESULT hStat;
        IAAFRoot * iObj;
        ImplAAFRoot *arg;
        hStat = pDescriptiveFramework->QueryInterface (IID_IAAFRoot, (void **)&iObj);
        assert (SUCCEEDED (hStat));
        assert (iObj);
        hStat = iObj->GetImplRep((void **)&arg);
        assert (SUCCEEDED (hStat));
        iObj->Release(); // we are through with this interface pointer.
        internalpDescriptiveFramework = static_cast<ImplAAFDescriptiveFramework*>(arg);
        assert (internalpDescriptiveFramework);
      }
  
    try
      {
        hr = ptr->SetDescriptiveFramework
         (internalpDescriptiveFramework);
      }
    catch (OMException& e)
      {
        // OMExceptions should be handled by the impl code. However, if an
        // unhandled OMException occurs, control reaches here. We must not
        // allow the unhandled exception to reach the client code, so we
        // turn it into a failure status code.
        //
        // If the OMException contains an HRESULT, it is returned to the
        // client, if not, AAFRESULT_UHANDLED_EXCEPTION is returned.
        //
        hr = OMExceptionToResult(e, AAFRESULT_UNHANDLED_EXCEPTION);
      }
    catch (OMAssertionViolation &)
      {
        // Control reaches here if there is a programming error in the
        // impl code that was detected by an assertion violation.
        // We must not allow the assertion to reach the client code so
        // here we turn it into a failure status code.
        //
        hr = AAFRESULT_ASSERTION_VIOLATION;
      }
    catch (...)
      {
        // We CANNOT throw an exception out of a COM interface method!
        // Return a reasonable exception code.
        //
        hr = AAFRESULT_UNEXPECTED_EXCEPTION;
      }
  
    //
    // no cleanup necessary for pDescriptiveFramework
    //
    return hr;
  }
  
  
  HRESULT STDMETHODCALLTYPE
      CAAFDescriptiveMarker::GetDescriptiveFramework (IAAFDescriptiveFramework ** ppDescriptiveFramework)
  {
    HRESULT hr;
  
    ImplAAFDescriptiveMarker * ptr;
    ImplAAFRoot * pO;
    pO = GetRepObject ();
    assert (pO);
    ptr = static_cast<ImplAAFDescriptiveMarker*> (pO);
    assert (ptr);
  
    //
    // set up for ppDescriptiveFramework
    //
    ImplAAFDescriptiveFramework * internalppDescriptiveFramework = NULL;
    ImplAAFDescriptiveFramework ** pinternalppDescriptiveFramework = NULL;
    if (ppDescriptiveFramework)
      {
        pinternalppDescriptiveFramework = &internalppDescriptiveFramework;
      }
  
    try
      {
        hr = ptr->GetDescriptiveFramework
         (pinternalppDescriptiveFramework);
      }
    catch (OMException& e)
      {
        // OMExceptions should be handled by the impl code. However, if an
        // unhandled OMException occurs, control reaches here. We must not
        // allow the unhandled exception to reach the client code, so we
        // turn it into a failure status code.
        //
        // If the OMException contains an HRESULT, it is returned to the
        // client, if not, AAFRESULT_UHANDLED_EXCEPTION is returned.
        //
        hr = OMExceptionToResult(e, AAFRESULT_UNHANDLED_EXCEPTION);
      }
    catch (OMAssertionViolation &)
      {
        // Control reaches here if there is a programming error in the
        // impl code that was detected by an assertion violation.
        // We must not allow the assertion to reach the client code so
        // here we turn it into a failure status code.
        //
        hr = AAFRESULT_ASSERTION_VIOLATION;
      }
    catch (...)
      {
        // We CANNOT throw an exception out of a COM interface method!
        // Return a reasonable exception code.
        //
        hr = AAFRESULT_UNEXPECTED_EXCEPTION;
      }
  
    //
    // cleanup for ppDescriptiveFramework
    //
    if (SUCCEEDED(hr))
      {
        IUnknown *pUnknown;
        HRESULT hStat;
  
        if (internalppDescriptiveFramework)
          {
            pUnknown = static_cast<IUnknown *> (internalppDescriptiveFramework->GetContainer());
            hStat = pUnknown->QueryInterface(IID_IAAFDescriptiveFramework, (void **)ppDescriptiveFramework);
            assert (SUCCEEDED (hStat));
            //pUnknown->Release();
            internalppDescriptiveFramework->ReleaseReference(); // We are through with this pointer.
            internalppDescriptiveFramework = 0;
          }
      }
  
    // If the call to the Impl method above fails, internalppDescriptiveFramework should
    // not be modified, check this with an assertion.
    //
    // If this assertion fails there's a programming error in the Impl
    // method above. Such a programming error also indicates a potential
    // memory leak.
    //
    assert (SUCCEEDED(hr) || internalppDescriptiveFramework == 0);
  
    return hr;
  }
  
  
  //
  // 
  // 
  inline int EQUAL_UID(const GUID & a, const GUID & b)
  {
    return (0 == memcmp((&a), (&b), sizeof (aafUID_t)));
  }
  HRESULT CAAFDescriptiveMarker::InternalQueryInterface
  (
      REFIID riid,
      void **ppvObj)
  {
      if (NULL == ppvObj)
          return E_INVALIDARG;
  
      // We only support the IClassFactory interface 
      if (EQUAL_UID(riid,IID_IAAFDescriptiveMarker)) 
      { 
          *ppvObj = (IAAFDescriptiveMarker *)this; 
          ((IUnknown *)*ppvObj)->AddRef();
          return S_OK;
      }
  
      // Always delegate back to base implementation.
      return CAAFCommentMarker::InternalQueryInterface(riid, ppvObj);
  }
  
  //
  // Define the contrete object support implementation.
  // 
  AAF_DEFINE_FACTORY(AAFDescriptiveMarker)
  
  