Logo
~Sockets~
~Examples~
~Contact~


SlaveHandler Class Reference

#include <SlaveHandler.h>

List of all members.


Public Member Functions

 SlaveHandler ()
 SlaveHandler (StdLog *)
 ~SlaveHandler ()
InternalSocketGetSock (unsigned short id)
SlaveSocketGetSlaveSocket ()
void LoadConfig ()
void SaveConfig ()
const std::string & GetRemoteHost ()
port_t GetRemotePort ()

Private Member Functions

 SlaveHandler (const SlaveHandler &)
SlaveHandleroperator= (const SlaveHandler &)

Private Attributes

std::string m_remote_host
port_t m_remote_port

Detailed Description

Definition at line 12 of file SlaveHandler.h.


Constructor & Destructor Documentation

SlaveHandler::SlaveHandler (  ) 

Definition at line 10 of file SlaveHandler.cpp.

00011 :SocketHandler()
00012 ,m_remote_port(23)
00013 {
00014 }

SlaveHandler::SlaveHandler ( StdLog *   ) 

Definition at line 17 of file SlaveHandler.cpp.

00018 :SocketHandler(p)
00019 ,m_remote_port(23)
00020 {
00021 }

SlaveHandler::~SlaveHandler (  ) 

Definition at line 24 of file SlaveHandler.cpp.

00025 {
00026 }

SlaveHandler::SlaveHandler ( const SlaveHandler  )  [inline, private]

Definition at line 30 of file SlaveHandler.h.

00030 {} // copy constructor


Member Function Documentation

InternalSocket * SlaveHandler::GetSock ( unsigned short  id  ) 

Definition at line 29 of file SlaveHandler.cpp.

00030 {
00031         for (socket_m::iterator it = m_sockets.begin(); it != m_sockets.end(); it++)
00032         {
00033                 Socket *p0 = (*it).second;
00034                 InternalSocket *p = dynamic_cast<InternalSocket *>(p0);
00035                 if (p && p -> GetID() == id)
00036                 {
00037                         return p;
00038                 }
00039         }
00040         return NULL;
00041 }

SlaveSocket * SlaveHandler::GetSlaveSocket (  ) 

Definition at line 72 of file SlaveHandler.cpp.

00073 {
00074         for (socket_m::iterator it = m_sockets.begin(); it != m_sockets.end(); it++)
00075         {
00076                 Socket *p0 = (*it).second;
00077                 SlaveSocket *p = dynamic_cast<SlaveSocket *>(p0);
00078                 if (p)
00079                 {
00080                         return p;
00081                 }
00082         }
00083         return NULL;
00084 }

void SlaveHandler::LoadConfig (  ) 

Definition at line 87 of file SlaveHandler.cpp.

References m_remote_host, and m_remote_port.

Referenced by main().

00088 {
00089         FILE *fil = fopen("slave.conf", "rt");
00090         if (fil)
00091         {
00092                 char slask[1000];
00093                 fgets(slask, 1000, fil);
00094                 while (!feof(fil))
00095                 {
00096                         slask[strlen(slask) - 1] = 0;
00097                         if (*slask && *slask != '#')
00098                         {
00099                                 Parse pa(slask);
00100                                 std::string key = pa.getword();
00101                                 std::string value = pa.getrest();
00102                                 if (key == "remote_host")
00103                                         m_remote_host = value;
00104                                 else
00105                                 if (key == "remote_port")
00106                                         m_remote_port = atoi(value.c_str());
00107                         }
00108                         //
00109                         fgets(slask, 1000, fil);
00110                 }
00111                 fclose(fil);
00112         }
00113 }

void SlaveHandler::SaveConfig (  ) 

Definition at line 116 of file SlaveHandler.cpp.

References m_remote_host, and m_remote_port.

Referenced by main().

00117 {
00118         FILE *fil = fopen("slave.conf", "wt");
00119         if (fil)
00120         {
00121                 fprintf(fil, "remote_host %s\n", m_remote_host.c_str());
00122                 fprintf(fil, "remote_port %u\n", m_remote_port);
00123                 fclose(fil);
00124         }
00125 }

const std::string& SlaveHandler::GetRemoteHost (  )  [inline]

Definition at line 26 of file SlaveHandler.h.

References m_remote_host.

Referenced by main().

00026 { return m_remote_host; }

port_t SlaveHandler::GetRemotePort (  )  [inline]

Definition at line 27 of file SlaveHandler.h.

References m_remote_port.

Referenced by main().

00027 { return m_remote_port; }

SlaveHandler& SlaveHandler::operator= ( const SlaveHandler  )  [inline, private]

Definition at line 31 of file SlaveHandler.h.

00031 { return *this; } // assignment operator


Member Data Documentation

std::string SlaveHandler::m_remote_host [private]

Definition at line 32 of file SlaveHandler.h.

Referenced by GetRemoteHost(), LoadConfig(), and SaveConfig().

port_t SlaveHandler::m_remote_port [private]

Definition at line 33 of file SlaveHandler.h.

Referenced by GetRemotePort(), LoadConfig(), and SaveConfig().


The documentation for this class was generated from the following files:
Page, code, and content Copyright (C) 2006 by Anders Hedström
Generated on Mon Aug 29 20:21:47 2005 for C++ Sockets by  doxygen 1.4.4