NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public Developers v
« Previous 1 … 76 77 78 79 80 … 93 Next »
implements IMenuTask, IEventNotification

 
  • 0 Vote(s) - 0 Average
implements IMenuTask, IEventNotification
reven
Offline

Posting Freak

Posts: 5,782
Threads: 396
Joined: Sep 2004
#1
2005-02-12, 05:01 PM
is there anyway to detect what is initializing the plugin and only create the things needed for each?  ie for IEventNotification i only use the one method Notify(EventTypes eventType, string eventText) and it uses nothing else of the plugin (nothing at all needs to be initiated) but everything is being created twice since it implements both of them.  anyway around this?  i could create another dll just for the IEventNotification, but that seems a little silly.

i may try making a few more things static and see if they have been created yet, but i cant do this for everything.  anyone got any ideas?



jasonf
Offline

Member

Posts: 121
Threads: 7
Joined: Oct 2004
#2
2005-02-12, 05:57 PM
Would using a Singleton help here?  There would only be 1 instance ever created.  Your IMenuTask and IEventNotification would serve as a pass-thru layer to an inner Singleton class.

To make a class into a singleton, you first make the constructors private.  Then you usually have a private static instance of the class that you expose through a public static method, which instantiates the object if it hasn't already been, and returns the private static instance.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
public class Class1
{
  private Class1()
  {
  }

  private static Class1 instance = null;

  public static Class1 GetInstance()
  {
     if (instance == null)
     {
        instance = new Class1();
     }
     return instance;
  }

  public void SomePublicMethod()
  {}
}
[/QUOTE]
JasonF
reven
Offline

Posting Freak

Posts: 5,782
Threads: 396
Joined: Sep 2004
#3
2005-02-12, 05:59 PM
and of course the obivous solution. thanks jasonf, yeah that will work. now i feel like an idiot [Image: smile.gif]
Jeff
Offline

Posting Freak

Posts: 1,933
Threads: 69
Joined: Oct 2004
#4
2005-02-12, 07:04 PM
What happens when GBPVR tries to create an instance of your class. I assume it doesn't know about the GteInstance method. I tried to accomplish the same thing by checking for an existing instance in my constructor and if I had already been ccreated I simply returned.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> public VAPanel()
{
// Don't run in the config app
if (PluginHelperFactory.getPluginHelper() == null) return;

if (instance != null) return;

instance = this;[/QUOTE]

It seems to work.

Jeff
jasonf
Offline

Member

Posts: 121
Threads: 7
Joined: Oct 2004
#5
2005-02-13, 12:19 PM
In the case of using a Singleton for a plugin, it's not the plugin itself that is the Singleton, but rather, it's some inner class that the plugin proxies.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
public class Plugin : IMenuTask
{
  public Plugin() {}

  public void Activate() { SingletonClass.GetInstance().Activate(); }

  public void render(out bool requiresMore)
  {
     SingletonClass.GetInstance().render(out requiresMore);
  }
}
[/QUOTE]
JasonF
reven
Offline

Posting Freak

Posts: 5,782
Threads: 396
Joined: Sep 2004
#6
2005-02-13, 12:49 PM
i just added another class that implements IEventNotification, since that class doesnt need to communicate or share any common values/objects with the IMenuTask class, its like they are two different plugins just compiled into the same dll. i feel like such an idiot for not thinkign of this [Image: tounge.gif]

the IEventNotification class just updates one field in the database, it sets a video file to seen when a user plays a video file, nothing special, just so if a user plays a video from anywhere in gbpvr it is displayed as seen (not sure how many people will find this feature useful, but i love it, i always forget what ive seen and what i havent).
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



Possibly Related Threads…
Thread Author Replies Views Last Post
  List of "IEventNotification" events? reven 8 3,389 2012-11-01, 10:56 PM
Last Post: reven
  Settings config screen for class IEventNotification plugin imilne 9 3,489 2011-09-17, 06:06 PM
Last Post: sub
  NPVR IEventNotification ralphy 12 5,079 2010-09-28, 11:39 PM
Last Post: pBS
  IMenuTask and IEventNotification not working well together since 0.98 psycik 5 2,173 2006-10-01, 05:27 PM
Last Post: sub
  IEventNotification for the bads tybreizh29 10 4,145 2004-11-05, 12:40 PM
Last Post: janviet
  [sub] IEventNotification, event pb tybreizh29 1 1,632 2004-11-01, 04:10 PM
Last Post: sub

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode