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

Public Member Functions

virtual void * cast (const std::string &a_class) const
 
virtual const std::string & s_cls () const
 
virtual bool write (io::iwbuf &a_buffer)
 
virtual bool read (io::irbuf &a_buffer)
 
virtual bool dump (std::ostream &a_out)
 
virtual bool s_value (std::string &a_s) const
 
virtual bool s2value (const std::string &a_s)
 
 sf_vec ()
 
 sf_vec (const T &a_value)
 
virtual ~sf_vec ()
 
 sf_vec (const sf_vec &a_from)
 
sf_vecoperator= (const sf_vec &a_from)
 
sf_vecoperator= (const T &a_value)
 
sf_vecoperator+= (const T &a_value)
 
- Public Member Functions inherited from tools::sg::bsf< T >
 bsf (const T &a_value)
 
virtual ~bsf ()
 
 bsf (const bsf &a_from)
 
bsfoperator= (const bsf &a_from)
 
bsfoperator= (const T &a_value)
 
bool operator== (const bsf &a_from) const
 
bool operator!= (const bsf &a_from) const
 
bool operator== (const T &a_value) const
 
bool operator!= (const T &a_value) const
 
 operator const T & () const
 
 operator T ()
 
T & value ()
 
const T & value () const
 
void value (const T &a_value)
 
void value_no_cmp (const T &a_value)
 
void setValue (const T &a_value)
 
const T & getValue () const
 
- Public Member Functions inherited from tools::sg::field
virtual ~field ()
 
void touch ()
 
bool touched () const
 
void reset_touched ()
 

Static Public Member Functions

static const std::string & s_class ()
 
- Static Public Member Functions inherited from tools::sg::bsf< T >
static const std::string & s_class ()
 

Additional Inherited Members

- Protected Member Functions inherited from tools::sg::bsf< T >
 bsf ()
 
- Protected Member Functions inherited from tools::sg::field
 field ()
 
 field (const field &)
 
fieldoperator= (const field &)
 
- Protected Attributes inherited from tools::sg::bsf< T >
m_value
 
- Protected Attributes inherited from tools::sg::field
bool m_touched
 

Detailed Description

template<class T, class TT>
class tools::sg::sf_vec< T, TT >

Definition at line 15 of file sf_vec.

Constructor & Destructor Documentation

◆ sf_vec() [1/3]

template<class T , class TT >
tools::sg::sf_vec< T, TT >::sf_vec ( )
inline

Definition at line 92 of file sf_vec.

92 :parent(){}

◆ sf_vec() [2/3]

template<class T , class TT >
tools::sg::sf_vec< T, TT >::sf_vec ( const T &  a_value)
inline

Definition at line 93 of file sf_vec.

93 :parent(a_value){}

◆ ~sf_vec()

template<class T , class TT >
virtual tools::sg::sf_vec< T, TT >::~sf_vec ( )
inlinevirtual

Definition at line 94 of file sf_vec.

94 {}

◆ sf_vec() [3/3]

template<class T , class TT >
tools::sg::sf_vec< T, TT >::sf_vec ( const sf_vec< T, TT > &  a_from)
inline

Definition at line 96 of file sf_vec.

97  :parent(a_from){}

Member Function Documentation

◆ cast()

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

Reimplemented from tools::sg::bsf< T >.

Definition at line 22 of file sf_vec.

22  {
23  if(void* p = cmp_cast< sf_vec<T,TT> >(this,a_class)) {return p;}
24  return parent::cast(a_class);
25  }

◆ dump()

template<class T , class TT >
virtual bool tools::sg::sf_vec< T, TT >::dump ( std::ostream &  a_out)
inlinevirtual

Implements tools::sg::field.

Definition at line 57 of file sf_vec.

57  {
58  a_out << parent::m_value << std::endl;
59  return true;
60  }

◆ operator+=()

template<class T , class TT >
sf_vec& tools::sg::sf_vec< T, TT >::operator+= ( const T &  a_value)
inline

Definition at line 107 of file sf_vec.

107  {
108  parent::value(parent::value()+a_value);
109  return *this;
110  }

◆ operator=() [1/2]

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

Definition at line 98 of file sf_vec.

98  {
99  parent::operator=(a_from);
100  return *this;
101  }

◆ operator=() [2/2]

template<class T , class TT >
sf_vec& tools::sg::sf_vec< T, TT >::operator= ( const T &  a_value)
inline

Definition at line 103 of file sf_vec.

103  {
104  parent::operator=(a_value);
105  return *this;
106  }

◆ read()

template<class T , class TT >
virtual bool tools::sg::sf_vec< T, TT >::read ( io::irbuf a_buffer)
inlinevirtual

Implements tools::sg::field.

Definition at line 33 of file sf_vec.

33  {
34  T& vec = parent::m_value;
35  uint32 n;
36  TT* v;
37  if(!a_buffer.read_vec(n,v)) {
38  //::printf("debug : sf_vec::read : failed(0).\n");
39  return false;
40  }
41  if(n!=vec.size()) {
42  delete [] v;
43 #ifdef TOOLS_MEM
44  mem::decrement(s_new().c_str());
45 #endif
46  //::printf("debug : sf_vec::read : failed(1) : %d (expected %d).\n",
47  // n,vec.size());
48  return false;
49  }
50  for(uint32 index=0;index<n;index++) vec[index] = v[index];
51  delete [] v;
52 #ifdef TOOLS_MEM
53  mem::decrement(s_new().c_str());
54 #endif
55  return true;
56  }

◆ s2value()

template<class T , class TT >
virtual bool tools::sg::sf_vec< T, TT >::s2value ( const std::string &  a_s)
inlinevirtual

Implements tools::sg::field.

Definition at line 72 of file sf_vec.

72  {
73  std::vector<std::string> ws;
74  words(a_s," ",false,ws);
75  T& vec = parent::m_value;
76  if(ws.size()!=vec.size()) return false;
77  T old_vec = vec;
78  for(size_t index=0;index<vec.size();index++) {
79  std::istringstream strm(ws[index].c_str());
80  TT v;
81  strm >> v;
82  if(strm.fail()) {
83  vec = old_vec;
84  return false;
85  }
86  if(vec[index]!=v) parent::m_touched = true;
87  vec[index] = v;
88  }
89  return true;
90  }

◆ s_class()

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

Definition at line 18 of file sf_vec.

18  {
19  static const std::string s_v("tools::sg::sf_vec<"+stype(T())+","+stype(TT())+">");
20  return s_v;
21  }

◆ s_cls()

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

Reimplemented from tools::sg::bsf< T >.

Definition at line 26 of file sf_vec.

26 {return s_class();}

◆ s_value()

template<class T , class TT >
virtual bool tools::sg::sf_vec< T, TT >::s_value ( std::string &  a_s) const
inlinevirtual

Implements tools::sg::field.

Definition at line 61 of file sf_vec.

61  {
62  a_s.clear();
63  const T& vec = parent::m_value;
64  for(size_t index=0;index<vec.size();index++) {
65  if(index) a_s += ' ';
66  std::ostringstream strm;
67  strm << vec[index];
68  a_s += strm.str();
69  }
70  return true;
71  }

◆ write()

template<class T , class TT >
virtual bool tools::sg::sf_vec< T, TT >::write ( io::iwbuf a_buffer)
inlinevirtual

Implements tools::sg::field.

Definition at line 28 of file sf_vec.

28  {
29  const T& vec = parent::m_value;
30  const TT* d = get_data(vec);
31  return a_buffer.write_vec(vec.size(),d);
32  }

The documentation for this class was generated from the following file:
tools::sg::field::m_touched
bool m_touched
Definition: field:63
tools::sg::bsf::m_value
T m_value
Definition: bsf:120
tools::sg::bsf::cast
virtual void * cast(const std::string &a_class) const
Definition: bsf:27
tools::words
void words(const std::string &a_string, const std::string &a_sep, bool a_take_empty, std::vector< std::string > &a_words, bool a_clear=true)
Definition: words:12
tools::cmp_cast
void * cmp_cast(const TO *a_this, const std::string &a_class)
Definition: scast:15
tools::sg::sf_vec::s_class
static const std::string & s_class()
Definition: sf_vec:18
tools::sg::get_data
const std::string * get_data(const std::vector< std::string > &a_v)
Definition: mf:191
tools::sg::bsf::operator=
bsf & operator=(const bsf &a_from)
Definition: bsf:49
tools::sg::bsf::value
T & value()
Definition: bsf:98
tools::stype
const std::string & stype(const mat4f &)
Definition: mat4f:73
tools::uint32
unsigned int uint32
Definition: typedefs:71