00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 #ifndef KVECTOR_HPP
00028 #define KVECTOR_HPP
00029 
00032 
00033 #include <vector>
00034 #include <string>
00035 #include <iostream>
00036 
00037 #include <kfilter/ktypes.hpp>
00038 
00039 namespace Kalman {
00040 
00042 
00071   template<typename T, K_UINT_32 BEG, bool DBG>
00072   class KVector {
00073   public:
00074 
00075     typedef T type;             
00076 
00077     enum { beg = BEG            
00078     };
00079 
00081 
00082 
00084     inline KVector();
00085 
00087     inline explicit KVector(K_UINT_32 n);
00088 
00090     inline KVector(K_UINT_32 n, const T& a);
00091 
00093     inline KVector(K_UINT_32 n, const T* v);
00094 
00096     inline KVector(const KVector& v);
00097 
00099     inline ~KVector();
00100 
00102 
00104 
00105 
00107     inline T& operator()(K_UINT_32 i);
00108 
00110     inline const T& operator()(K_UINT_32 i) const;
00111 
00113     inline K_UINT_32 size() const;
00114 
00116 
00118     inline void resize(K_UINT_32 n);
00119 
00121     inline KVector& operator=(const T& a);
00122 
00124     inline KVector& operator=(const KVector& v);
00125 
00127     inline void assign(K_UINT_32 n, const T* v);
00128 
00130     inline void swap(KVector& v);
00131 
00133 
00134 
00136     inline void get(std::istream& is);
00137 
00139     inline void put(std::ostream& os) const;
00140 
00142 
00143   private:
00144     std::vector<T> vimpl_;      
00145     
00147 
00151     T* v_;
00152     K_UINT_32 n_;               
00153   };
00154 
00156   template<typename T, K_UINT_32 BEG, bool DBG>
00157   inline std::istream& operator>>(std::istream& is, 
00158                                   KVector<T, BEG, DBG>& v);
00159 
00161   template<typename T, K_UINT_32 BEG, bool DBG>
00162   inline std::ostream& operator<<(std::ostream& os, 
00163                                   const KVector<T, BEG, DBG>& v);
00164 
00166   typedef unsigned short KVectorContext;
00167 
00169   extern KVectorContext DEFAULT_VECTOR_CONTEXT;
00170 
00172   KVectorContext createKVectorContext(std::string elemDelim = " ", 
00173                                       std::string startDelim = "", 
00174                                       std::string endDelim = "", 
00175                                       unsigned prec = 4);
00176 
00178   KVectorContext selectKVectorContext(KVectorContext c);
00179 }
00180 
00181 #include <kfilter/kvector_impl.hpp>
00182 
00183 #endif