AutovectorImpl.h
Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 //  (c) 2012 by Teledyne DALSA
00003 //  Section: Digital Imaging
00004 //  Project: GenAPI
00005 //  Author:  Eric Bourbonnais
00006 //
00007 //  License: This file is published under the license of the EMVA GenICam  Standard Group. 
00008 //  A text file describing the legal terms is included in  your installation as 'GenICam_license.pdf'. 
00009 //  If for some reason you are missing  this file please contact the EMVA or visit the website
00010 //  (http://www.genicam.org) for a full copy.
00011 // 
00012 //  THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS"
00013 //  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,  
00014 //  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR  
00015 //  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD  GROUP 
00016 //  OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,  SPECIAL, 
00017 //  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT  LIMITED TO, 
00018 //  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,  DATA, OR PROFITS; 
00019 //  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY  THEORY OF LIABILITY, 
00020 //  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT  (INCLUDING NEGLIGENCE OR OTHERWISE) 
00021 //  ARISING IN ANY WAY OUT OF THE USE  OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
00022 //  POSSIBILITY OF SUCH DAMAGE.
00023 //-----------------------------------------------------------------------------
00024 //
00030 
00031 
00032 #ifndef GENAPI_GCAUTIVECTOR_H
00033 #define GENAPI_GCAUTIVECTOR_H
00034 
00035 #include "GenApi/Autovector.h"
00036 #ifdef _MSC_VER
00037 #   include "GenApi/impl/GlobalPragmas.h"
00038 #endif
00039 #include "GenApi/impl/Value2String.h"
00040 #include <algorithm>
00041 
00042 
00043 namespace GENAPI_NAMESPACE
00044 {
00045     template<class T, class Base>
00046     class _autovector_impl : public Base
00047     {
00048     public:
00049         _autovector_impl() : Base()
00050         {};
00051 
00052         _autovector_impl(const _autovector_impl &obj) : Base(obj)
00053         {};
00054 
00055         explicit _autovector_impl(const size_t uiSize)
00056         {
00057             // fill with uiSize default values
00058             Base::_pv->reserve(uiSize);
00059             for (size_t i = 0; i < uiSize; ++i)
00060             {
00061                 Base::_pv->push_back(T());
00062             }
00063         };
00064 
00065         _autovector_impl(T *values, const size_t count)
00066         {
00067             Base::_pv->reserve(count);
00068             for (size_t index = 0; index < count; index++)
00069                 Base::_pv->push_back(values[index]);
00070             std::sort(Base::_pv->begin(), Base::_pv->end());
00071 
00072         };
00073 
00074         virtual ~_autovector_impl() {}
00075 
00076         void ToStrings(GENICAM_NAMESPACE::gcstring_vector &srtList) const
00077         {
00078             GENICAM_NAMESPACE::gcstring valueStr;
00079             typename std::vector<T>::const_iterator it;
00080             for (it = Base::_pv->begin(); it != Base::_pv->end(); it++)
00081             {
00082                 Value2String(*it, valueStr);
00083                 srtList.push_back(valueStr);
00084             }
00085         };
00086 
00087         _autovector_impl & operator= (const Base &obj)
00088         {
00089             Base::operator=(obj);
00090             return *this;
00091         }
00092         _autovector_impl & operator= (const _autovector_impl &obj)
00093         {
00094             Base::operator=(obj);
00095             return *this;
00096         }
00097 
00098         _autovector_impl & operator= (const GENICAM_NAMESPACE::gcstring_vector &obj)
00099         {
00100             Base::_pv->clear();
00101             for (GENICAM_NAMESPACE::gcstring_vector::const_iterator it = obj.begin();
00102                 it != obj.end(); it++)
00103             {
00104                 T value;
00105                 if (String2Value(*it, &value))
00106                     Base::_pv->push_back(value);
00107             }
00108             std::sort(Base::_pv->begin(), Base::_pv->end());
00109             return *this;
00110         }
00111 
00112         const _autovector_impl duplicate(T min, T max)
00113         {
00114             _autovector_impl resizeVect;
00115             typename std::vector<T>::const_iterator it;
00116             for (it = Base::_pv->begin(); it != Base::_pv->end(); it++)
00117             {
00118                 if (*it >= min && *it <= max)
00119                     resizeVect._pv->push_back(*it);
00120             }
00121             return resizeVect;
00122         };
00123 
00124         size_t size() const
00125         {
00126             return Base::size();
00127         }
00128 
00129     };
00130 
00131     typedef _autovector_impl<int64_t, int64_autovector_t> int64_autovector_impl;
00132     typedef _autovector_impl<double, double_autovector_t> double_autovector_impl;
00133 }
00134 
00135 #endif // GENICAM_GCAUTIVECTOR_H


rc_genicam_api
Author(s): Heiko Hirschmueller
autogenerated on Thu Jun 6 2019 18:42:46