×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Feb 2007
    Posts
    14

    CleanupStack , ambiguous acces

    Hi,
    To begin : some samples of my code. (S60 FP3)

    // MyAppUi.h
    class CMyAppUi : public CAknViewAppUi
    {
    public:
    void ConstructL();
    CMyAppUi();
    ~CMyAppUi();

    public:
    virtual void HandleCommandL(TInt aCommand);
    CSettingsData* iData;
    private:
    CAudioPlayerTools* iTools;
    };

    //MyAppUi.cpp
    void CGlobalAppUi::ConstructL()
    {
    BaseConstructL();
    iData = CSettingsData::NewL();

    iTools = CAudioPlayerTools::NewL(ClientRect());
    iTools->SetMopParent(this);
    AddToStackL(iTools);

    CAknView* view;
    view = CGlobalView::NewLC(*iData);
    AddViewL(view);
    CleanupStack::Pop(view);
    ActivateLocalViewL(view->Id());

    Cba()->MakeVisible(ETrue);
    }

    CGlobalAppUi::CGlobalAppUi()
    {
    }

    CGlobalAppUi::~CGlobalAppUi()
    {
    delete iData;
    if (iTools)
    {
    RemoveFromStack(iTools);
    delete iTools;
    }
    }

    //AudioPlayerEngine.h
    #include "myappui.h"
    lass CAudioPlayerEngine : public CBase,
    public MMdaAudioToneObserver,
    public MMdaAudioPlayerCallback,
    public MMdaAudioOutputStreamCallback,
    public CMyAppUi
    {
    public:
    enum TState{ EStopped, EPlaying };

    public:
    static CAudioPlayerEngine* NewL(MAudioPlayerEngineObserver& aObserver);
    ~CAudioPlayerEngine();

    public: // MMdaAudioToneObserver
    virtual void MatoPrepareComplete(TInt aError);
    virtual void MatoPlayComplete(TInt aError);

    public: // MMdaAudioPlayerCallback
    virtual void MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& aDuration);
    virtual void MapcPlayComplete(TInt aError);

    public: // MMdaAudioOutputStreamCallback
    virtual void MaoscOpenComplete(TInt aError);
    virtual void MaoscBufferCopied(TInt aError, const TDesC8& aBuffer);
    virtual void MaoscPlayComplete(TInt aError);

    public:
    void PlayToneL();
    void PlayWavL();
    void PlayMidiL();
    void PlayStreamL();
    void Stop();
    //CSettingsData* iData;
    public:
    inline const TState& State() const;

    private:
    CAudioPlayerEngine(MAudioPlayerEngineObserver& aObserver);
    void ConstructL();

    private:
    MAudioPlayerEngineObserver& iObserver;
    CMdaAudioPlayerUtility* iPlayerFile;
    CMdaAudioToneUtility* iPlayerTone;
    CMdaAudioOutputStream* iPlayerStream;
    TMdaAudioDataSettings iStreamSettings;
    TUint8* iStreamData;
    TPtr8* iStreamBuffer;
    TState iState;

    };

    //AudioEnginePlayer.cpp
    AudioPlayerEngine::CAudioPlayerEngine(MAudioPlayerEngineObserver& aObserver)
    :iObserver(aObserver),
    iState(EStopped)
    {
    }
    CAudioPlayerEngine::~CAudioPlayerEngine()
    {
    Stop();
    }


    CAudioPlayerEngine* CAudioPlayerEngine::NewL(MAudioPlayerEngineObserver& aObserver)
    {
    CAudioPlayerEngine* self = new (ELeave) CAudioPlayerEngine(aObserver);
    CleanupStack::PushL(self); //ambiguous access here from CAudioPlayerEngine to CBase self->ConstructL();
    CleanupStack::Pop(self);
    return self;
    }

    void CAudioPlayerEngine::ConstructL()
    {
    }

    In fact, I absolutely need using the pointer iData (declared in MyAppUi) in the file AudioPlayerEngine.cpp.
    For that CAudioPlayerEngine inherits CMyAppUi but it leads to an ambiguity.

    As I'm a beginner in C++ and Symbian, I'm not sure of the constructors, destructors and private or public declarations.

    So my aim is to use the same iData in MyAppUi and in AudioPlayerEngine.
    How can I delete this ambiguity ?
    Or is there another solution to do this ?

    Thanks in anticipation for your answers.

  2. #2
    Super Contributor
    Join Date
    Jun 2005
    Location
    Beijing
    Posts
    5,578

    Re: CleanupStack , ambiguous acces

    To use multiple inheritance you can inherit one C-class only,others can be M-class.Please refer to SDK» Developer Library » Symbian OS Guide » Essential idioms » Multiple inheritance and interfaces
    Beover1984
    -----------
    Doing what comes naturally

  3. #3
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,167

    Re: CleanupStack , ambiguous acces

    Basically you could pass a pointer/reference to your Appui and use it's public functions inside your class (or just cast the Appui pointer you can get with CEikonEnv), or pass a pointer/reference to a interface definition that implements required functions for the data access.

    yucca

Similar Threads

  1. CleanupStack Problem
    By siddhartha84 in forum Symbian
    Replies: 10
    Last Post: 2007-01-08, 12:31
  2. Can you Peek at the CleanupStack?
    By loginssuck in forum Symbian
    Replies: 2
    Last Post: 2006-06-16, 17:23
  3. Error is ambiguous. Can you help me ?
    By hovannhan in forum Symbian
    Replies: 2
    Last Post: 2005-02-21, 14:32
  4. What is CleanUpStack?
    By burnik in forum Symbian
    Replies: 3
    Last Post: 2004-12-21, 09:45
  5. CleanupStack Question
    By royzhou in forum Symbian
    Replies: 3
    Last Post: 2003-07-22, 08:21

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×