00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012
00018 #ifndef _CVM_BASE_CHANNEL_H_
00019 #define _CVM_BASE_CHANNEL_H_
00020
00021 #include "ace/Dynamic_Service.h"
00022
00023 #include <Channel.h>
00024 #include <CvmService.h>
00025
00026 #include <iostream>
00027 #include <vector>
00028 #include <string>
00029
00030
00031 namespace cvm {
00032
00035 template <class Channel>
00036 class CvmBaseChannel : public CvmService {
00037 public:
00038 Channel ch_;
00039 Channel * chan(void) { return &ch_; }
00040
00042 virtual int init (int argc, ACE_TCHAR *argv[])
00043 {
00044 ACE_UNUSED_ARG(argc);
00045 ACE_UNUSED_ARG(argv);
00046
00047 ACE_DEBUG((LM_DEBUG, "### Channel is up and running ... ###\n"));
00048 return 0;
00049 }
00050 virtual int close (u_long)
00051 {
00052
00053 return 0;
00054 }
00055 virtual int fini ()
00056 {
00057 ACE_DEBUG((LM_DEBUG, "### Channel [%s] is shuting down ... ###\n", name().c_str()));
00058
00059 ACE_DEBUG((LM_DEBUG, "Channel/Connector shutdown and ask all reader/writer threads exit...\n"));
00060 ACE_DEBUG((LM_DEBUG, "all reader/writeer threads exit...\n"));
00061 ACE_DEBUG((LM_DEBUG, "shutdown clock thread now...\n"));
00062 channel::Clock::instance()->stop();
00063 ACE_DEBUG((LM_DEBUG, "clock thread exit...\n"));
00064
00065 ACE_OS::sleep(1);
00066 return 0;
00067 }
00068 virtual int info (ACE_TCHAR **strp, size_t length = 0) const
00069 {
00070 char buf[256];
00071
00072 ACE_OS::sprintf (buf,
00073 "CvmBaseChannel coming up ... \n");
00074
00075 if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0)
00076 return -1;
00077 else
00078 ACE_OS::strncpy (*strp, buf, length);
00079 return ACE_OS::strlen (buf);
00080 }
00081
00082
00083
00084 static Channel *find_chan(const char* name)
00085 {
00086 CvmBaseChannel<Channel> *d = ACE_Dynamic_Service<CvmBaseChannel<Channel> >::instance(ACE_TEXT(name));
00087 if (d==NULL)
00088 return NULL;
00089 else
00090 return d->chan();
00091 }
00092 };
00093
00094 };
00095
00096 #endif