LightWrap++
AC++wrapperfortheLightWave3DSDK
comring.h
Go to the documentation of this file.
1 #ifndef COMRING_COMMUNICATOR_H
2 #define COMRING_COMMUNICATOR_H
3 
4 #include <lwpp/global.h>
5 #include <lwcomring.h>
6 #include <string>
7 
8 namespace lwpp
9 {
12 
15  class comRingCommunicator : public GlobalBase<LWComRing> // needs to be declared as a global properly in global.cpp
16  {
17  std::string lastTopic;
18  protected:
20 
23  virtual void RingEvent(void *portData, int eventCode, void *eventData)
24  {
25  return;
26  }
28  static void RingEventCB(void *clientData, void *portData,int eventCode,void *eventData)
29  {
30  // cast the instance back to the base class
31  comRingCommunicator *plugin = static_cast<comRingCommunicator *>(clientData);
32  // pass through the remaining arguments to the function
33  plugin->RingEvent(portData, eventCode, eventData);
34  }
35  public:
40  comRingCommunicator(const char *topic)
41  {
42  if (available())
43  {
44  if (ringAttach (topic))
45  {
46  ;
47  }
48  }
49  }
51  {
52  if (!lastTopic.empty()) ringDetach (lastTopic.c_str());
53  }
55  bool ringAttach (const char *topic)
56  {
57  if (globPtr->ringAttach(const_cast<char *>(topic), this, RingEventCB))
58  {
59  lastTopic = topic;
60  return true;
61  }
62  return false;
63  }
64 
66  void ringDetach (const char *topic)
67  {
68  globPtr->ringDetach(const_cast<char *>(topic), this);
69  }
70 
72  void ringMessage (const char *topic,int eventCode,void *eventData = 0)
73  {
74  if (globPtr) globPtr->ringMessage(const_cast<char *>(topic), eventCode, eventData);
75  }
76  };
77 
78 #ifndef LW_PLUGIN_LIMBO_STATES
79 #define LW_PLUGIN_LIMBO_STATES "LW Plugin Limbo States"
80 
81 #define LW_LIMBO_START 0x00000001
82 #define LW_LIMBO_END 0x00000002
83 #endif
84 
86 
92  {
93  public:
95  {
97  }
99  {
101  }
102  };
103 
104 } // end namespace
105 #endif // COMRING_COMMUNICATOR_H