LightWrap++
AC++wrapperfortheLightWave3DSDK
channel_handler.h
Go to the documentation of this file.
1 #ifndef LWPP_CHANNEL_HANDLER_H
2 #define LWPP_CHANNEL_HANDLER_H
3 
4 #include "lwpp/plugin_handler.h"
5 #include <lwchannel.h>
6 
7 namespace lwpp
8 {
10  {
11  protected:
13  public:
14  ChannelHandler(void* g, void* context, LWError* err)
15  : InstanceHandler(g,context,err, LWCHANNEL_HCLASS)
16  {
17  Context.SetID(LWItemID(context));
18  }
19  virtual ~ChannelHandler()
20  {
21  ;
22  }
23 
24  virtual void Evaluate(const LWChannelAccess *ca)
25  {
26  ;
27  }
28  virtual unsigned int Flags()
29  {
30  return 0; //says This Plugin doesn't get applied after IK by default.
31  }
32  };
33 
35  template <class T, int min, int max>
36  class ChannelAdaptor : public InstanceAdaptor <T>
37  {
38  public:
39  ChannelAdaptor(const char *name, ServerTagInfo *tags)
40  {
41  LWServer::AddPlugin(LWITEMMOTION_HCLASS, name, Activate, tags);
42  }
43  static int Activate (int version , GlobalFunc* global, LWInstance inst, void* serverData)
44  {
45  if(version!=LWCHANNEL_VERSION) return AFUNC_BADVERSION;
46  lwpp::SetSuperGlobal(global);
47 
48  LWChannelHandler* plugin = static_cast<LWChannelHandler*>(inst);
49  InstanceAdaptor<T>::Activate(plugin->inst);
50  ItemAdaptor<T>::Activate(plugin->item);
51 
52  plugin->evaluate = ItemMotionAdaptor::Evaluate;
53  plugin->flags = ItemMotionAdaptor::Flags;
54 
55  UNUSED(serverData);
56  return AFUNC_OK;
57  }
58  private:
59  static void Evaluate (LWInstance inst, const LWChannelAccess* ma)
60  {
61  T* plugin = static_cast<T*>(inst);
62  plugin->Evaluate(ma);
63  }
64  static unsigned int Flags (LWInstance inst)
65  {
66  T* plugin = static_cast<T*>(inst);
67  return plugin->Flags();
68  }
69  };
70 
71  /* GUI Classes */
80 }
81 
82 #endif //LWPP_CHANNEL_HANDLER_H