• Main Page
  • Packages
  • Classes
  • Files
  • File List
  • File Members

unlock/bci/acquire-c++/Sample.hpp

Go to the documentation of this file.
00001 
00002 // Copyright (c) James Percent and Unlock contributors.
00003 // All rights reserved.
00004 // Redistribution and use in source and binary forms, with or without modification,
00005 // are permitted provided that the following conditions are met:
00006 //
00007 //    1. Redistributions of source code must retain the above copyright notice,
00008 //       this list of conditions and the following disclaimer.
00009 //    
00010 //    2. Redistributions in binary form must reproduce the above copyright
00011 //       notice, this list of conditions and the following disclaimer in the
00012 //       documentation and/or other materials provided with the distribution.
00013 //
00014 //    3. Neither the name of Unlock nor the names of its contributors may be used
00015 //       to endorse or promote products derived from this software without
00016 //       specific prior written permission.
00017 
00018 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00019 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00020 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00021 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
00022 // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00023 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00024 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
00025 // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00026 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00027 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00028 
00029 #ifndef SAMPLE_HPP
00030 #define SAMPLE_HPP
00031 
00032 #include <cstddef>
00033 #include "Portability.hpp"
00034 
00035 template<class T>
00036 class DllExport Sample
00037 {
00038  public:
00039   Sample() : mpSample(0), mLength(0) {}
00040     
00041   Sample(const Sample& copy) : mpSample(copy.mpSample), mLength(copy.mLength) {
00042   }
00043     
00044   ~Sample() {
00045     mpSample = 0;
00046     mLength = 0;
00047   }
00048     
00049   Sample& operator=(const Sample& other) {
00050     mpSample = other.mpSample;
00051     mLength = other.mLength;
00052     return *this;
00053   }
00054     
00055   void configure(T* pSample, int length) {
00056     mpSample = pSample;
00057     mLength = length;        
00058   }
00059  
00060   T* sample() {
00061     return (T*)mpSample;
00062   }
00063     
00064   size_t length() {
00065     return (size_t)mLength;
00066   }
00067     
00068  private:   
00069   volatile T* mpSample;
00070   volatile size_t mLength;
00071 };
00072 
00073 #endif

Generated on Mon Nov 10 2014 11:09:08 for The Unlock Project by  doxygen 1.7.1