VR-Link API Documentation for DIS
vlFileTransport.h
Go to the documentation of this file.
1 /*********************************************************************
2 ** Copyright (c) 2004 MaK Technologies, Inc.
3 ** All rights reserved.
4 *********************************************************************/
5 /*********************************************************************
6 ** $RCSfile: vlFileTransport.h,v $ $Revision: 1.2.6.1 $ $State: Exp $
7 *********************************************************************/
8 #ifndef vlFileTransport_H_
9 #define vlFileTransport_H_
10 
14 
15 #ifndef VXWORKS
16 
17 #include <vlutil/vlFilename.h>
18 #include <vlutil/vlString.h>
19 #include <vlutil/vlUtil.h>
20 #include "vlSocket.h"
21 
22 #include <fstream>
23 #include <map>
24 
25 #ifdef DtUSE_UTILITIES_NAMESPACE
26 namespace DtUSE_UTILITIES_NAMESPACE
27 {
28 #endif
29 
30 
31 class DtTcpSocket;
32 class DtTcpSocketMgr;
33 
35 {
36 public:
39 
41 
45  unsigned long myBufferLength;
46  unsigned long myBytesReceived;
47  std::vector<char> myBuffer;
48  int myFlags;
49 };
50 
52 {
53 public:
54 
55  typedef void (*DtFileTransferedCallbackFn)
56  (const DtFilename& file, void* usr);
57 
58  typedef std::map<int, DtFileTransportObject> DtFileObjectMap;
59 
61  {
62  DtFileNormal = 0,
63  DtFileCompressed = 1,
64  DtFileEncrypted = 2
65  };
66 
67 public:
68 
77  int port = DtDEFAULT_PORT,
78  bool findFirstAvailable = false,
79  int portRangeToTry = 10,
80  const DtFilename &tagetDirectory = ".",
81  int *status = 0);
82 
84  virtual ~DtFileTransporter();
85 
87  virtual void tick();
88 
91  virtual unsigned int port() const;
92 
95  virtual void addFileTransferedCallback(
96  DtFileTransferedCallbackFn fn, void* data);
97  virtual void removeFileTransferedCallback(
98  DtFileTransferedCallbackFn fn, void* data);
99 
101  virtual bool sendFile(
102  const DtFilename& filename, DtIpv4Addr destAddr, int port);
103 
105  virtual bool sendFile(
106  const DtFilename& filename, DtIpv4Addr destAddr);
107 
112  const DtFilename& targetDirectory() const;
113  void setTargetDirectory(const DtFilename& f);
114 
115 public:
116 
118  static void receiveFileCb(DtTcpSocket* sock, void* usr);
119 
120 protected:
121 
126  virtual void receiveFile(DtTcpSocket* sock);
127 
131  virtual int nextFileIdentifier();
132 
139  virtual bool readFileToBuffer(std::ifstream& inFile,
140  std::vector<char>& fileBuffer, int fileLengthInBytes, int& retBufLen,
141  DtFileTransportFlags& flags);
142 
144  virtual void finishFile(DtFileTransportObject& object);
145 
146  virtual DtFileTransportObject& transportObject(int iFileIdentifier);
147 
148 protected:
149 
152 
154  DtFileTransporter& operator=(const DtFileTransporter&);
155 
156 protected:
157 
158  typedef std::map<DtFileTransferedCallbackFn, void*> FileTransferedCallbackMapType;
159 
160 protected:
161 
163  int myPort;
166 
168 };
169 
170 #ifdef DtUSE_UTILITIES_NAMESPACE
171 }
172 #endif
173 
174 #endif
175 
176 
177 
178 #endif
179 
180 

Document ID: Generated on Wed Aug 14 15:35:11 EDT 2013 from SVN revision 130445
Copyright © 2005-2013 VT MÄK. All Rights Reserved (www.mak.com)