Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VsnetDownload::Client::Item Class Referenceabstract

#include <vsnet_notify.h>

Inheritance diagram for VsnetDownload::Client::Item:
VsnetDownload::Client::Buffer VsnetDownload::Client::File VsnetDownload::Client::TestItem VsnetDownload::Client::NoteFile

Public Member Functions

 Item (SOCKETALT sock, const std::string &filename, VSFileSystem::VSFileType=VSFileSystem::UnknownFile, NotifyPtr notify=NotifyPtr())
 
virtual ~Item ()
 
State state () const
 
VSError error () const
 
void changeState (State s)
 
void changeState (State s, VSError e)
 
void setFileType (VSFileSystem::VSFileType ft)
 
VSFileSystem::VSFileType getFileType ()
 
void setSize (int len)
 
void append (unsigned char *buffer, int bufsize)
 
const std::string & getFilename () const
 
SOCKETALT getSock () const
 
int get_fd () const
 

Protected Member Functions

virtual void childSetSize (int len)=0
 
virtual void childAppend (unsigned char *buffer, int bufsize)=0
 
void protected_replace_notifier (NotifyPtr ptr)
 

Protected Attributes

VSFileSystem::VSFileType _filetype
 

Detailed Description

Definition at line 172 of file vsnet_notify.h.

Constructor & Destructor Documentation

VsnetDownload::Client::Item::Item ( SOCKETALT  sock,
const std::string &  filename,
VSFileSystem::VSFileType  = VSFileSystem::UnknownFile,
NotifyPtr  notify = NotifyPtr() 
)

Definition at line 45 of file vsnet_notify.cpp.

45  :
46  _filetype( ft )
47  , _sock( sock )
48  , _filename( filename )
49  , _state( Idle )
50  , _error( Ok )
51  , _notify( notify )
52 {}
VsnetDownload::Client::Item::~Item ( )
virtual

Definition at line 54 of file vsnet_notify.cpp.

55 {}

Member Function Documentation

void VsnetDownload::Client::Item::append ( unsigned char *  buffer,
int  bufsize 
)

Definition at line 88 of file vsnet_notify.cpp.

References childAppend().

89 {
91  if (_notify) _notify->addBytes( bufsize );
92 }
void VsnetDownload::Client::Item::changeState ( State  s)

Definition at line 94 of file vsnet_notify.cpp.

References COUT, e, int, VSMutex::lock(), and VSMutex::unlock().

Referenced by VsnetDownload::Client::Manager::addItems().

95 {
96  COUT<<__FUNCTION__<<" "<<s<<" "<<(int) _error<<endl;
97 
98  _mx.lock();
99  _state = s;
100  VSError e = _error;
101  _mx.unlock();
102  if (_notify) _notify->notify( s, e );
103 }
void VsnetDownload::Client::Item::changeState ( State  s,
VSError  e 
)

Definition at line 105 of file vsnet_notify.cpp.

References COUT, int, VSMutex::lock(), and VSMutex::unlock().

106 {
107  COUT<<__FUNCTION__<<" "<<s<<" "<<(int) e<<endl;
108 
109  _mx.lock();
110  _state = s;
111  _error = e;
112  _mx.unlock();
113  if (_notify) _notify->notify( s, e );
114 }
virtual void VsnetDownload::Client::Item::childAppend ( unsigned char *  buffer,
int  bufsize 
)
protectedpure virtual
virtual void VsnetDownload::Client::Item::childSetSize ( int  len)
protectedpure virtual
VSError VsnetDownload::Client::Item::error ( ) const

Definition at line 65 of file vsnet_notify.cpp.

References VSMutex::lock(), and VSMutex::unlock().

66 {
67  _mx.lock();
68  VSError ret = _error;
69  _mx.unlock();
70  return ret;
71 }
int VsnetDownload::Client::Item::get_fd ( ) const

Definition at line 126 of file vsnet_notify.cpp.

References SOCKETALT::get_fd().

127 {
128  return _sock.get_fd();
129 }
const string & VsnetDownload::Client::Item::getFilename ( ) const

Definition at line 116 of file vsnet_notify.cpp.

Referenced by VsnetDownload::Client::Manager::addItems().

117 {
118  return _filename;
119 }
VSFileSystem::VSFileType VsnetDownload::Client::Item::getFileType ( )

Definition at line 77 of file vsnet_notify.cpp.

References _filetype.

78 {
79  return _filetype;
80 }
SOCKETALT VsnetDownload::Client::Item::getSock ( ) const

Definition at line 121 of file vsnet_notify.cpp.

122 {
123  return _sock;
124 }
void VsnetDownload::Client::Item::protected_replace_notifier ( NotifyPtr  ptr)
protected

Definition at line 131 of file vsnet_notify.cpp.

Referenced by VsnetDownload::Client::Buffer::Buffer(), and VsnetDownload::Client::NoteFile::NoteFile().

132 {
133  _notify = ptr;
134 }
void VsnetDownload::Client::Item::setFileType ( VSFileSystem::VSFileType  ft)

Definition at line 72 of file vsnet_notify.cpp.

References _filetype.

73 {
74  _filetype = ft;
75 }
void VsnetDownload::Client::Item::setSize ( int  len)

Definition at line 82 of file vsnet_notify.cpp.

References childSetSize().

83 {
84  childSetSize( len );
85  if (_notify) _notify->setTotalBytes( len );
86 }
State VsnetDownload::Client::Item::state ( ) const

Definition at line 57 of file vsnet_notify.cpp.

References VSMutex::lock(), and VSMutex::unlock().

58 {
59  _mx.lock();
60  State ret = _state;
61  _mx.unlock();
62  return ret;
63 }

Member Data Documentation

VSFileSystem::VSFileType VsnetDownload::Client::Item::_filetype
protected

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