g4tools  5.4.0
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
tools::sg::bmf< T > Class Template Reference
Inheritance diagram for tools::sg::bmf< T >:
Inheritance graph
[legend]
Collaboration diagram for tools::sg::bmf< T >:
Collaboration graph
[legend]

Public Types

typedef std::vector< T >::iterator it_t
 

Public Member Functions

virtual void * cast (const std::string &a_class) const
 
virtual const std::string & s_cls () const
 
 bmf ()
 
 bmf (const T &a_value)
 
 bmf (const std::vector< T > &a_v)
 
virtual ~bmf ()
 
 bmf (const bmf &a_from)
 
bmfoperator= (const bmf &a_from)
 
bmfoperator= (const std::vector< T > &a_from)
 
bool operator== (const bmf &a_from) const
 
bool operator!= (const bmf &a_from) const
 
const T & operator[] (size_t a_index) const
 
T & operator[] (size_t a_index)
 
size_t size () const
 
bool empty () const
 
const std::vector< T > & values () const
 
std::vector< T > & values ()
 
void add (const T &a_value)
 
void add (const std::vector< T > &a_vals)
 
void add_allocated (size_t &a_pos, const T &a_1, const T &a_2, const T &a_3)
 
void insert (const it_t &a_it, const T &a_value)
 
bool set_value (size_t a_index, const T &a_value)
 
bool get_value (size_t a_index, T &a_value)
 
void clear ()
 
void set_values (const std::vector< T > &a_values)
 
void set_value (const T &a_value)
 
bool setValues (size_t a_index, size_t a_num, const T *a_vs)
 
bool set1Value (size_t a_index, const T &a_value)
 
bool setValue (const T &a_value)
 
bmfoperator= (const T &a_v)
 
size_t getNum () const
 
T * getValues (size_t a_start)
 
- Public Member Functions inherited from tools::sg::field
virtual bool write (io::iwbuf &)=0
 
virtual bool read (io::irbuf &)=0
 
virtual bool dump (std::ostream &)=0
 
virtual bool s_value (std::string &) const =0
 
virtual bool s2value (const std::string &)=0
 
virtual ~field ()
 
void touch ()
 
bool touched () const
 
void reset_touched ()
 

Static Public Member Functions

static const std::string & s_class ()
 

Protected Attributes

std::vector< T > m_values
 
- Protected Attributes inherited from tools::sg::field
bool m_touched
 

Additional Inherited Members

- Protected Member Functions inherited from tools::sg::field
 field ()
 
 field (const field &)
 
fieldoperator= (const field &)
 

Detailed Description

template<class T>
class tools::sg::bmf< T >

Definition at line 21 of file bmf.

Member Typedef Documentation

◆ it_t

template<class T >
typedef std::vector<T>::iterator tools::sg::bmf< T >::it_t

Definition at line 92 of file bmf.

Constructor & Destructor Documentation

◆ bmf() [1/4]

template<class T >
tools::sg::bmf< T >::bmf ( )
inline

Definition at line 36 of file bmf.

36 {}

◆ bmf() [2/4]

template<class T >
tools::sg::bmf< T >::bmf ( const T &  a_value)
inline

Definition at line 37 of file bmf.

37 {m_values.push_back(a_value);}

◆ bmf() [3/4]

template<class T >
tools::sg::bmf< T >::bmf ( const std::vector< T > &  a_v)
inline

Definition at line 38 of file bmf.

38 {m_values = a_v;}

◆ ~bmf()

template<class T >
virtual tools::sg::bmf< T >::~bmf ( )
inlinevirtual

Definition at line 39 of file bmf.

39 {m_values.clear();}

◆ bmf() [4/4]

template<class T >
tools::sg::bmf< T >::bmf ( const bmf< T > &  a_from)
inline

Definition at line 41 of file bmf.

41 :parent(a_from),m_values(a_from.m_values){}

Member Function Documentation

◆ add() [1/2]

template<class T >
void tools::sg::bmf< T >::add ( const std::vector< T > &  a_vals)
inline

Definition at line 77 of file bmf.

77  {
78  if(a_vals.empty()) return;
79  typedef typename std::vector<T>::const_iterator const_it_t;
80  for(const_it_t it=a_vals.begin();it!=a_vals.end();++it){
81  m_values.push_back(*it);
82  }
83  m_touched = true;
84  }

◆ add() [2/2]

template<class T >
void tools::sg::bmf< T >::add ( const T &  a_value)
inline

Definition at line 73 of file bmf.

73  {
74  m_values.push_back(a_value);
75  m_touched = true;
76  }

◆ add_allocated()

template<class T >
void tools::sg::bmf< T >::add_allocated ( size_t &  a_pos,
const T &  a_1,
const T &  a_2,
const T &  a_3 
)
inline

Definition at line 85 of file bmf.

85  { //used in sg::plotter.
86  std::vector<T>& v = m_values;
87  v[a_pos] = a_1;a_pos++;
88  v[a_pos] = a_2;a_pos++;
89  v[a_pos] = a_3;a_pos++;
90  m_touched = true;
91  }

◆ cast()

template<class T >
virtual void* tools::sg::bmf< T >::cast ( const std::string &  a_class) const
inlinevirtual

◆ clear()

template<class T >
void tools::sg::bmf< T >::clear ( )
inline

Definition at line 108 of file bmf.

108  {
109  if(m_values.size()) m_touched = true;
110  m_values.clear();
111  }

◆ empty()

template<class T >
bool tools::sg::bmf< T >::empty ( ) const
inline

Definition at line 70 of file bmf.

70 {return m_values.empty();}

◆ get_value()

template<class T >
bool tools::sg::bmf< T >::get_value ( size_t  a_index,
T &  a_value 
)
inline

Definition at line 103 of file bmf.

103  {
104  if(a_index>=m_values.size()) {a_value=T();return false;}
105  a_value = m_values[a_index];
106  return true;
107  }

◆ getNum()

template<class T >
size_t tools::sg::bmf< T >::getNum ( ) const
inline

Definition at line 156 of file bmf.

156 {return m_values.size();}

◆ getValues()

template<class T >
T* tools::sg::bmf< T >::getValues ( size_t  a_start)
inline

Definition at line 157 of file bmf.

157  { //for gopaw.
158  if(a_start>=(m_values.size()+1)) return 0;
159  T* data = vec_data(m_values);
160  return data+a_start;
161  }

◆ insert()

template<class T >
void tools::sg::bmf< T >::insert ( const it_t a_it,
const T &  a_value 
)
inline

Definition at line 93 of file bmf.

93  {
94  m_values.insert(a_it,a_value);
95  m_touched = true;
96  }

◆ operator!=()

template<class T >
bool tools::sg::bmf< T >::operator!= ( const bmf< T > &  a_from) const
inline

Definition at line 57 of file bmf.

57  {
58  return !operator==(a_from);
59  }

◆ operator=() [1/3]

template<class T >
bmf& tools::sg::bmf< T >::operator= ( const bmf< T > &  a_from)
inline

Definition at line 42 of file bmf.

42  {
43  parent::operator=(a_from);
44  if(a_from.m_values!=m_values) m_touched = true;
45  m_values = a_from.m_values;
46  return *this;
47  }

◆ operator=() [2/3]

template<class T >
bmf& tools::sg::bmf< T >::operator= ( const std::vector< T > &  a_from)
inline

Definition at line 49 of file bmf.

49  {
50  if(a_from!=m_values) m_touched = true;
51  m_values = a_from;
52  return *this;
53  }

◆ operator=() [3/3]

template<class T >
bmf& tools::sg::bmf< T >::operator= ( const T &  a_v)
inline

Definition at line 152 of file bmf.

152  {
153  if(!setValue(a_v)) {}
154  return *this;
155  }

◆ operator==()

template<class T >
bool tools::sg::bmf< T >::operator== ( const bmf< T > &  a_from) const
inline

Definition at line 54 of file bmf.

54  {
55  return m_values==a_from.m_values;
56  }

◆ operator[]() [1/2]

template<class T >
T& tools::sg::bmf< T >::operator[] ( size_t  a_index)
inline

Definition at line 64 of file bmf.

64  {
65  //WARNING : no check is done on a_index.
66  return m_values[a_index];
67  }

◆ operator[]() [2/2]

template<class T >
const T& tools::sg::bmf< T >::operator[] ( size_t  a_index) const
inline

Definition at line 60 of file bmf.

60  {
61  //WARNING : no check is done on a_index.
62  return m_values[a_index];
63  }

◆ s_class()

template<class T >
static const std::string& tools::sg::bmf< T >::s_class ( )
inlinestatic

Definition at line 24 of file bmf.

24  {
25  //we do not use stype(T()).
26  static const std::string s_v("tools::sg::bmf");
27  return s_v;
28  }

◆ s_cls()

template<class T >
virtual const std::string& tools::sg::bmf< T >::s_cls ( ) const
inlinevirtual

◆ set1Value()

template<class T >
bool tools::sg::bmf< T >::set1Value ( size_t  a_index,
const T &  a_value 
)
inline

Definition at line 144 of file bmf.

144  {
145  if(a_index>=m_values.size()) m_values.resize(a_index+1);
146  if(m_values[a_index]!=a_value) m_touched = true;
147  m_values[a_index] = a_value;
148  return true;
149  }

◆ set_value() [1/2]

template<class T >
void tools::sg::bmf< T >::set_value ( const T &  a_value)
inline

Definition at line 117 of file bmf.

117  { //used in ArcheryTune.
118  bool to_resize = m_values.size()==1?false:true;
119  bool is_eq = ( (m_values.size()>=1) && (m_values[0]==a_value) ) ? true : false;
120  if(to_resize) m_values.resize(1);
121  if(to_resize || !is_eq) m_touched = true;
122  m_values[0] = a_value;
123  }

◆ set_value() [2/2]

template<class T >
bool tools::sg::bmf< T >::set_value ( size_t  a_index,
const T &  a_value 
)
inline

Definition at line 97 of file bmf.

97  {
98  if(a_index>=m_values.size()) return false;
99  if(m_values[a_index]!=a_value) m_touched = true;
100  m_values[a_index] = a_value;
101  return true;
102  }

◆ set_values()

template<class T >
void tools::sg::bmf< T >::set_values ( const std::vector< T > &  a_values)
inline

Definition at line 113 of file bmf.

113  {
114  if(a_values!=m_values) m_touched = true;
115  m_values = a_values;
116  }

◆ setValue()

template<class T >
bool tools::sg::bmf< T >::setValue ( const T &  a_value)
inline

Definition at line 150 of file bmf.

150 {set_value(a_value);return true;}

◆ setValues()

template<class T >
bool tools::sg::bmf< T >::setValues ( size_t  a_index,
size_t  a_num,
const T *  a_vs 
)
inline

Definition at line 133 of file bmf.

133  {
134  // 012345678
135  // 234
136  if((a_index+a_num)>=m_values.size()) m_values.resize(a_index+a_num);
137  for(size_t index=0;index<a_num;index++) {
138  if(a_vs[index]!=m_values[a_index+index]) m_touched = true;
139  m_values[a_index+index] = a_vs[index];
140  }
141  return true;
142  }

◆ size()

template<class T >
size_t tools::sg::bmf< T >::size ( ) const
inline

Definition at line 69 of file bmf.

69 {return m_values.size();}

◆ values() [1/2]

template<class T >
std::vector<T>& tools::sg::bmf< T >::values ( )
inline

Definition at line 72 of file bmf.

72 {return m_values;}

◆ values() [2/2]

template<class T >
const std::vector<T>& tools::sg::bmf< T >::values ( ) const
inline

Definition at line 71 of file bmf.

71 {return m_values;}

Member Data Documentation

◆ m_values

template<class T >
std::vector<T> tools::sg::bmf< T >::m_values
protected

Definition at line 163 of file bmf.


The documentation for this class was generated from the following file:
tools::sg::field::m_touched
bool m_touched
Definition: field:63
tools::vec_data
const T * vec_data(const std::vector< T > &a_vec)
Definition: vdata:18
tools::sg::field::cast
virtual void * cast(const std::string &a_class) const
Definition: field:28
tools::sg::field::operator=
field & operator=(const field &)
Definition: field:57
tools::sg::bmf::s_class
static const std::string & s_class()
Definition: bmf:24
tools::sg::bmf::operator==
bool operator==(const bmf &a_from) const
Definition: bmf:54
tools::sg::bmf::set_value
bool set_value(size_t a_index, const T &a_value)
Definition: bmf:97
tools::cmp_cast
void * cmp_cast(const TO *a_this, const std::string &a_class)
Definition: scast:15
tools::sg::bmf::m_values
std::vector< T > m_values
Definition: bmf:163
tools::sg::bmf::setValue
bool setValue(const T &a_value)
Definition: bmf:150