Changeset 26:77a23a961301 in xplra for src
- Timestamp:
- 02/07/13 18:58:46 (12 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/client/c/hu/varadiistvan/xplra
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/client/c/hu/varadiistvan/xplra/MultiBuffer.cc
r22 r26 141 141 //------------------------------------------------------------------------------ 142 142 143 void MultiBuffer::forgetRegistration() throw() 144 { 145 registeredID = -1; 146 } 147 148 //------------------------------------------------------------------------------ 149 143 150 inline const MultiBuffer::DataRef* MultiBuffer::getLastDataRef() const throw() 144 151 { -
src/client/c/hu/varadiistvan/xplra/MultiBuffer.h
r22 r26 155 155 uint8_t unregisterCommand) throw(); 156 156 157 public:158 157 /** 159 158 * Destroy the buffer. If it is registered, an attempt will be … … 162 161 virtual ~MultiBuffer() throw(Exception); 163 162 163 public: 164 164 /** 165 165 * Add an integer dataref. … … 477 477 478 478 /** 479 * Forget the registration of this buffer. This is called from the 480 * destructor of the XPlane object, since that closes the 481 * connection anyway, so there is no need to unregister the 482 * multi-buffers. 483 */ 484 void forgetRegistration() throw(); 485 486 /** 479 487 * Get the last dataref, or 0 if there are not datarefs yet. 480 488 */ … … 524 532 getArray(size_t id, size_t offset) const 525 533 throw(InvalidIDException, TypeMismatchException); 534 535 friend class XPlane; 526 536 }; 527 537 -
src/client/c/hu/varadiistvan/xplra/MultiGetter.h
r22 r26 44 44 class MultiGetter : public MultiBuffer 45 45 { 46 p ublic:46 private: 47 47 /** 48 48 * Construct the object for the given XPlane instance. … … 67 67 */ 68 68 void read(const DataRef& dataRef) throw(Exception); 69 70 friend class XPlane; 69 71 }; 70 72 -
src/client/c/hu/varadiistvan/xplra/MultiSetter.h
r22 r26 44 44 class MultiSetter : public MultiBuffer 45 45 { 46 p ublic:46 private: 47 47 /** 48 48 * Construct the object for the given XPlane instance. … … 67 67 */ 68 68 void write(const DataRef& dataRef) const throw(Exception); 69 70 friend class XPlane; 69 71 }; 70 72 -
src/client/c/hu/varadiistvan/xplra/XPlane.cc
r19 r26 31 31 #include "XPlane.h" 32 32 33 #include "MultiGetter.h" 34 #include "MultiSetter.h" 35 33 36 #include <hu/varadiistvan/scpl/io/LocalClientSocket.h> 34 37 #include <hu/varadiistvan/scpl/io/DataStream.h> … … 41 44 42 45 using hu::varadiistvan::xplra::XPlane; 46 using hu::varadiistvan::xplra::MultiGetter; 47 using hu::varadiistvan::xplra::MultiSetter; 43 48 44 49 using hu::varadiistvan::scpl::io::LocalClientSocket; … … 104 109 { 105 110 disconnect(); 111 for(multiBuffers_t::iterator i = multiBuffers.begin(); 112 i!=multiBuffers.end(); ++i) 113 { 114 MultiBuffer* buffer = *i; 115 buffer->forgetRegistration(); 116 delete buffer; 117 } 106 118 } 107 119 … … 138 150 delete stream; stream = 0; 139 151 delete socket; socket = 0; 152 } 153 154 //------------------------------------------------------------------------------ 155 156 MultiGetter& XPlane::createMultiGetter() throw() 157 { 158 MultiGetter* getter = new MultiGetter(*this); 159 multiBuffers.insert(getter); 160 return *getter; 161 } 162 163 //------------------------------------------------------------------------------ 164 165 MultiSetter& XPlane::createMultiSetter() throw() 166 { 167 MultiSetter* setter = new MultiSetter(*this); 168 multiBuffers.insert(setter); 169 return *setter; 170 } 171 172 //------------------------------------------------------------------------------ 173 174 bool XPlane::destroyMultiBuffer(MultiBuffer& buffer) throw(Exception) 175 { 176 multiBuffers_t::iterator i = multiBuffers.find(&buffer); 177 if (i==multiBuffers.end()) return false; 178 179 multiBuffers.erase(i); 180 delete &buffer; 181 182 return true; 140 183 } 141 184 -
src/client/c/hu/varadiistvan/xplra/XPlane.h
r19 r26 35 35 #include <hu/varadiistvan/scpl/io/Waiter.h> 36 36 37 #include <set> 38 37 39 #include <inttypes.h> 38 40 … … 49 51 50 52 namespace hu { namespace varadiistvan { namespace xplra { 53 54 //------------------------------------------------------------------------------ 55 56 class MultiBuffer; 57 class MultiGetter; 58 class MultiSetter; 51 59 52 60 //------------------------------------------------------------------------------ … … 61 69 private: 62 70 /** 71 * Type for the set of multi-dataref buffers. 72 */ 73 typedef std::set<MultiBuffer*> multiBuffers_t; 74 75 /** 63 76 * The waiter to use. 64 77 */ … … 74 87 */ 75 88 scpl::io::DataStream* stream; 89 90 /** 91 * The buffers created by this object. 92 */ 93 multiBuffers_t multiBuffers; 76 94 77 95 public: … … 84 102 /** 85 103 * Destroy the object. If connected, the connection will be 86 * closed. 104 * closed. It destroys all existing buffers, so their references 105 * become invalid. 87 106 */ 88 107 ~XPlane() throw(); … … 102 121 */ 103 122 void disconnect() throw(); 123 124 /** 125 * Create a new getter of multiple datarefs and return a reference 126 * to it. 127 */ 128 MultiGetter& createMultiGetter() throw(); 129 130 /** 131 * Create a new setter of multiple datarefs and return a reference 132 * to it. 133 */ 134 MultiSetter& createMultiSetter() throw(); 135 136 /** 137 * Destroy the given getter or setter of multiple datarefs. As the 138 * buffer is unregistered, if it has been registered previously, 139 * and unregistration may fail, this function might throw an 140 * exception. 141 * 142 * @return if the buffer was found and could be destroyed 143 */ 144 bool destroyMultiBuffer(MultiBuffer& buffer) throw(Exception); 104 145 105 146 /**
Note:
See TracChangeset
for help on using the changeset viewer.