Using both CQikBase as well as CActive

Login to reply to this topic.
Wed, 2008-07-02 07:29
Joined: 2008-07-02
Forum posts: 7

HI,
I am encountering a strange situation and how some of you have a solution.

[1] I an trying to develop a UI for media player which will inherit from CQikBase of UIQ.
[2] From this UI, i have to call CVideoPlayerUtility->CustomCommandAsync.
[3] But this requires me to provide a TRequestStatus parameter which will be available if my UI class derieves from CActive.
[4] Problem here is i cannot derieve from Both CQikBase as well as CActive at the same time.

[5] I have thought of a solution which is to have a seperate Class which derieves from CActive and have a pointer of this class in my UI. But i dnt want to do this due to various reasons.

Any altername solution so that i can derieve from Both CQikBase and CActive at the same time.

Regds
Hitesh


Wed, 2008-07-02 08:08
Joined: 2003-12-05
Forum posts: 672
Re: Using both CQikBase as well as CActive

Your only option is to do the thing you do not want to do, as you described.

Wed, 2008-07-02 08:12
Joined: 2005-04-13
Forum posts: 121
Re: Using both CQikBase as well as CActive

go with the Observer pattern as

class CA: public CQikBase, public MObserverActiveObject
{

// from MObserverActiveObject
void listeningfunc();
private:
CB* iActiveObjectInstance;
}

CA:NewL()
{
..
cb = CB::NewL(*this);
}
void CA::listeningfunc()
{
// do your function here
}

class MObserverActiveObject
{
virtual void listeningfunc() =0;
}

class CB::public CActive
{
CB(MObserverActiveObject& aObserver);
static CB* NewL(MObserverActiveObject& aObserver);
RunL();
DoCancel();
private:
MObserverActiveObject& iObserver;
}

CB:CB(MObserverActiveObject& aObserver):
CActive(<<>>>)
iObserver(aObserver)
{
CActiveScheduler::Add(this);
}

CB* CB::(MObserverActiveObject& aObserver)
{
CB* self = new (ELeave) CB(aObserver)
...
.

}
CB::RunL()
{
...
...
..
..

iObserver.listeningfunc();
...
...
...
}

Hope it will help in solving your problem. Smiling


Jupitar

Wed, 2008-07-02 08:22
Joined: 2005-04-13
Forum posts: 121
Re: Using both CQikBase as well as CActive

yeah, its probably the same as you said not to do in point 5[ i didnt read carefully. :)]


Jupitar

Wed, 2008-07-02 08:32
Joined: 2008-07-02
Forum posts: 7
Re: Using both CQikBase as well as CActive

Ya but this solution looks better than having a pointer of CA in my CB class.

Atleast now CB class donot have access to all methods and variables of CA, it can just access few Api's and i am safe in This.

Thanks Jupiter for this solution.

Wed, 2008-07-02 09:30
Joined: 2005-04-13
Forum posts: 121
Re: Using both CQikBase as well as CActive

gr8. All the best for your work. Go ahead.


Jupitar

Wed, 2008-07-02 13:07
Joined: 2008-07-02
Forum posts: 7
Re: Using both CQikBase as well as CActive

Hi Jupitar,

I am getting few error while compiling itself, and i tried to check them out, but i could not do so.

[1] Can you pls elaborate this code upto certain extent.
Especially the declaration of CB. (It NewL not required ????)
And also at the Default constructor of CB.

Please help me...

Thu, 2008-07-03 06:14
Joined: 2005-04-13
Forum posts: 121
Re: Using both CQikBase as well as CActive

Compilatation Error!! I didnt compile it. I just given you an approach. If you look carefully, you should be able to resolve them. Btw, can you please share the error message.


Jupitar

  • Login to reply to this topic.