//
//  HA_buffer.h
//  HA_server
//
//  Created by hark on 2013/07/03.
//  Copyright (c) 2013年 hark. All rights reserved.
//

#ifndef __HA_server__HA_buffer__
#define __HA_server__HA_buffer__

#ifdef __cplusplus

#include "HA_log.h"
#include "floatx8.h"
#include "ringbuffer.h"

namespace HARKAndroid {
    
class BufferObject : public HAObject {
private:
    ringbuffer<floatx8> buffer;

public:
    BufferObject(const BufferObject&);
    BufferObject();
	explicit BufferObject(const unsigned int default_size = 65536);
	virtual ~BufferObject();
	BufferObject& operator = (const BufferObject&);

//    int writeWithTimeout(const floatx8& dat, const unsigned int timeout_ms) {
//        return(buffer.write(dat, timeout_ms));
//    }
    
    int writeWithTimeout(const std::vector<floatx8>& dat, const unsigned int timeout_ms) {
        return(buffer.write(dat, timeout_ms));
    }

//    int write(const floatx8& dat) {
//        return(buffer.write(dat));
//    }

//    int readWithTimeout(floatx8& dat, const unsigned int timeout_ms) {
//        return(buffer.read(dat, timeout_ms));
//    }
    
    int readWithTimeout(std::vector<floatx8>& dat, const unsigned int timeout_ms) {
        return(buffer.read(dat, timeout_ms));
    }
    
//    int read(floatx8& dat) {
//        return(buffer.read(dat));
//    }
    
    int clear() {
        return(buffer.clear());
    }
    
    unsigned int getlen() const {
        return(buffer.getlen());
    }
    
    unsigned int getdatnum() {
        return(buffer.getdatnum());
    }
};

} // end of namespace

#endif // __cplusplus

#endif /* defined(__HA_server__HA_buffer__) */
