PEBL 2.2
Psychology Experiment Building Language - Cross-platform psychological experiment development system
PNetwork Class Reference

#include <PNetwork.h>

Inheritance diagram for PNetwork:
PDevice PEBLObjectBase PlatformNetwork

Public Member Functions

 PNetwork ()
 The Standard constructor.

 
virtual ~PNetwork ()
 The Standard destructor.

 
virtual void SetHostIP (unsigned int host)
 
virtual unsigned int GetHost ()
 
virtual void SetHostName (std::string hostname)
 
virtual std::string GetHostName ()
 
virtual void SetPort (unsigned int port)
 
virtual unsigned int GetPort ()
 
virtual bool IsOpen ()
 
virtual Variant ConvertAddress (unsigned long int address)
 
virtual void SetOpen (bool open)
 
- Public Member Functions inherited from PDevice
 PDevice ()
 The Standard constructor.
 
virtual ~PDevice ()
 The Standard destructor.
 
virtual PEBL_DEVICE_TYPE GetDeviceType ()
 
virtual int GetState (int iface) const
 
- Public Member Functions inherited from PEBLObjectBase
 PEBLObjectBase ()
 Standard Constructor.
 
 PEBLObjectBase (ComplexDataType cdt)
 Standard Constructor.
 
 PEBLObjectBase (const PEBLObjectBase &pob)
 
virtual ~PEBLObjectBase ()
 Standard Destructor.
 
virtual bool InitializeProperty (std::string name, Variant v)
 
virtual bool SetProperty (std::string name, Variant v)
 
Variant GetProperty (std::string) const
 
virtual ObjectValidationError ValidateProperty (std::string, Variant v) const
 
virtual ObjectValidationError ValidateProperty (std::string) const
 
ComplexDataType GetType ()
 
virtual std::string ObjectName () const
 
virtual std::ostream & PrintProperties (std::ostream &out)
 
virtual Variant GetPropertyList ()
 

Protected Member Functions

virtual std::ostream & SendToStream (std::ostream &out) const
 

Protected Attributes

std::string mHostName
 
unsigned int mHost
 
unsigned int mPort
 
bool mIsOpen
 
- Protected Attributes inherited from PEBLObjectBase
ComplexDataType mCDT
 
std::map< std::string, VariantmProperties
 

Detailed Description

This is the base File Stream class.
It is used to read and write files. It is also a subclass of PDevice, which means that it can be added to the event loop for interesting between-process communications, and probably even used as a basis for other input devices.

Definition at line 43 of file PNetwork.h.

Constructor & Destructor Documentation

◆ PNetwork()

PNetwork::PNetwork ( )

The Standard constructor.

Definition at line 37 of file PNetwork.cpp.

37 :
38 mHostName(""),
39 mHost(0),
40 mPort(0),
41 mIsOpen(false)
42{
43 InitializeProperty("NAME","<NETWORK>");
44 InitializeProperty("HOSTNAME",0);
45 InitializeProperty("HOSTIP",0);
46 InitializeProperty("PORT",0);
47 InitializeProperty("ISOPEN",0);
49}
@ CDT_NETWORKCONNECTION
Definition PEBLObject.h:64
virtual bool InitializeProperty(std::string name, Variant v)
ComplexDataType mCDT
Definition PEBLObject.h:109
bool mIsOpen
Definition PNetwork.h:77
std::string mHostName
Definition PNetwork.h:73
unsigned int mPort
Definition PNetwork.h:75
unsigned int mHost
Definition PNetwork.h:74

References CDT_NETWORKCONNECTION, PEBLObjectBase::InitializeProperty(), and PEBLObjectBase::mCDT.

◆ ~PNetwork()

PNetwork::~PNetwork ( )
virtual

The Standard destructor.

Definition at line 52 of file PNetwork.cpp.

53{
54}

Member Function Documentation

◆ ConvertAddress()

Variant PNetwork::ConvertAddress ( unsigned long int  address)
virtual

Definition at line 57 of file PNetwork.cpp.

58{
59 //Uint32 address;
60
61 unsigned char octet[4] = {0,0,0,0};
62 for (int i=0; i<4; i++)
63 {
64 octet[i] = (address >> (i*8) ) & 0xFF;
65 }
66 Variant v = "";
67 v = v+Variant(octet[3])+
68 Variant(".")+Variant(octet[2])+
69 Variant(".")+ Variant(octet[1])+
70 Variant(".")+ Variant(octet[0]);
71 return v;
72}

Referenced by SetHostIP().

◆ GetHost()

unsigned int PNetwork::GetHost ( )
virtual

Definition at line 86 of file PNetwork.cpp.

87{
88 return mHost;
89}

References mHost.

◆ GetHostName()

std::string PNetwork::GetHostName ( )
virtual

Definition at line 103 of file PNetwork.cpp.

104{
105 return mHostName;
106}

References mHostName.

◆ GetPort()

unsigned int PNetwork::GetPort ( )
virtual

Definition at line 114 of file PNetwork.cpp.

115 {
116 return mPort;
117 }

References mPort.

◆ IsOpen()

bool PNetwork::IsOpen ( )
virtual

Definition at line 119 of file PNetwork.cpp.

119 {
120 return mIsOpen;
121};

References mIsOpen.

◆ SendToStream()

ostream & PNetwork::SendToStream ( std::ostream &  out) const
protectedvirtual

Reimplemented from PDevice.

Reimplemented in PlatformNetwork.

Definition at line 73 of file PNetwork.cpp.

74{
75 out << "<Generic Network Object>" << flush;
76 return out;
77}

◆ SetHostIP()

void PNetwork::SetHostIP ( unsigned int  host)
virtual

Definition at line 81 of file PNetwork.cpp.

81 {
82 mHost = host;
84}
virtual bool SetProperty(std::string name, Variant v)
virtual Variant ConvertAddress(unsigned long int address)
Definition PNetwork.cpp:57

References ConvertAddress(), mHost, and PEBLObjectBase::SetProperty().

◆ SetHostName()

void PNetwork::SetHostName ( std::string  hostname)
virtual

Definition at line 97 of file PNetwork.cpp.

98{
99 PEBLObjectBase::SetProperty("HOSTNAME",hostname);
100 mHostName = hostname;
101}

References mHostName, and PEBLObjectBase::SetProperty().

◆ SetOpen()

void PNetwork::SetOpen ( bool  open)
virtual

Definition at line 91 of file PNetwork.cpp.

92{
93 mIsOpen = open;
94 PEBLObjectBase::SetProperty("ISOPEN",open);
95}

References mIsOpen, and PEBLObjectBase::SetProperty().

◆ SetPort()

void PNetwork::SetPort ( unsigned int  port)
virtual

Definition at line 108 of file PNetwork.cpp.

109{
110 mPort = port;
112}

References mPort, and PEBLObjectBase::SetProperty().

Member Data Documentation

◆ mHost

unsigned int PNetwork::mHost
protected

Definition at line 74 of file PNetwork.h.

Referenced by GetHost(), and SetHostIP().

◆ mHostName

std::string PNetwork::mHostName
protected

Definition at line 73 of file PNetwork.h.

Referenced by GetHostName(), and SetHostName().

◆ mIsOpen

bool PNetwork::mIsOpen
protected

Definition at line 77 of file PNetwork.h.

Referenced by IsOpen(), and SetOpen().

◆ mPort

unsigned int PNetwork::mPort
protected

Definition at line 75 of file PNetwork.h.

Referenced by GetPort(), and SetPort().


The documentation for this class was generated from the following files: