foobar2000 SDK  2015-08-03
Public Member Functions | Private Member Functions | Private Attributes
config_object_impl

#include <config_object_impl.h>

+ Inheritance diagram for config_object_impl:

Public Member Functions

 config_object_impl (const GUID &p_guid, const void *p_data, t_size p_bytes)
 
void get_data (stream_writer *p_stream, abort_callback &p_abort) const
 
GUID get_guid () const
 
void set_data (stream_reader *p_stream, abort_callback &p_abort, bool p_notify)
 
- Public Member Functions inherited from config_object
 FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT (config_object)
 
void get_data_bool (bool &p_out)
 
bool get_data_bool_simple (bool p_default)
 
void get_data_int32 (t_int32 &p_out)
 
t_int32 get_data_int32_simple (t_int32 p_default)
 
t_size get_data_raw (void *p_out, t_size p_bytes)
 
t_size get_data_raw_length ()
 
void get_data_string (pfc::string_base &p_out)
 
template<class T >
void get_data_struct_t (T &p_out)
 
void set_data_bool (bool p_val)
 
void set_data_int32 (t_int32 p_val)
 
void set_data_raw (const void *p_data, t_size p_bytes, bool p_sendnotify=true)
 
void set_data_string (const char *p_data, t_size p_length)
 
template<class T >
void set_data_struct_t (const T &p_in)
 
- Public Member Functions inherited from service_base
template<typename outPtr_t >
bool cast (outPtr_t &outPtr)
 
virtual int service_add_ref ()=0 throw ()
 
virtual bool service_query (service_ptr_t< service_base > &p_out, const GUID &p_guid)
 
template<class T >
bool service_query_t (service_ptr_t< T > &p_out)
 
virtual int service_release ()=0 throw ()
 

Private Member Functions

void get_data_raw (stream_writer *p_stream, abort_callback &p_abort)
 
void set_data_raw (stream_reader *p_stream, t_size p_sizehint, abort_callback &p_abort)
 
- Private Member Functions inherited from cfg_var
GUID get_guid () const
 
 cfg_var (const GUID &p_guid)
 
- Private Member Functions inherited from cfg_var_reader
 cfg_var_reader (const GUID &guid)
 
 ~cfg_var_reader ()
 
- Private Member Functions inherited from cfg_var_writer
 cfg_var_writer (const GUID &guid)
 
 ~cfg_var_writer ()
 

Private Attributes

pfc::array_t< t_uint8m_data
 
critical_section m_sync
 
- Private Attributes inherited from cfg_var_reader
const GUID m_guid
 
- Private Attributes inherited from cfg_var_writer
const GUID m_guid
 

Additional Inherited Members

- Public Types inherited from service_base
typedef service_base t_interface
 
- Static Public Member Functions inherited from config_object
static bool g_find (service_ptr_t< config_object > &p_out, const GUID &p_guid)
 
static void g_get_data_bool (const GUID &p_guid, bool &p_out)
 
static bool g_get_data_bool_simple (const GUID &p_guid, bool p_default)
 
static void g_get_data_int32 (const GUID &p_guid, t_int32 &p_out)
 
static t_int32 g_get_data_int32_simple (const GUID &p_guid, t_int32 p_default)
 
static void g_get_data_string (const GUID &p_guid, pfc::string_base &p_out)
 
template<class T >
static void g_get_data_struct_t (const GUID &p_guid, T &p_out)
 
static void g_set_data_bool (const GUID &p_guid, bool p_val)
 
static void g_set_data_int32 (const GUID &p_guid, t_int32 p_val)
 
static void g_set_data_string (const GUID &p_guid, const char *p_data, t_size p_length=~0)
 
template<class T >
static void g_set_data_struct_t (const GUID &p_guid, const T &p_in)
 
- Protected Member Functions inherited from service_base
 service_base ()
 
 ~service_base ()
 
- Static Private Member Functions inherited from cfg_var_reader
static void config_read_file (stream_reader *p_stream, abort_callback &p_abort)
 
- Static Private Member Functions inherited from cfg_var_writer
static void config_write_file (stream_writer *p_stream, abort_callback &p_abort)
 

Detailed Description

Definition at line 31 of file config_object_impl.h.

Constructor & Destructor Documentation

config_object_impl::config_object_impl ( const GUID p_guid,
const void *  p_data,
t_size  p_bytes 
)

Definition at line 211 of file config_object.cpp.

211  : cfg_var(p_guid)
212 {
213  m_data.set_data_fromptr((const t_uint8*)p_data,p_bytes);
214 }
uint8_t t_uint8
Definition: int_types.h:9
cfg_var(const GUID &p_guid)
Definition: cfg_var.h:57
pfc::array_t< t_uint8 > m_data
void set_data_fromptr(const t_source *p_buffer, t_size p_count)
Warning: buffer pointer must not point to buffer allocated by this array (fixme). ...
Definition: array.h:139

Member Function Documentation

void config_object_impl::get_data ( stream_writer p_stream,
abort_callback p_abort 
) const
virtual

Implements config_object.

Definition at line 182 of file config_object.cpp.

182  {
183  insync(m_sync);
184  p_stream->write_object(m_data.get_ptr(),m_data.get_size(),p_abort);
185 }
critical_section m_sync
const t_item * get_ptr() const
Definition: array.h:213
pfc::array_t< t_uint8 > m_data
t_size get_size() const
Definition: array.h:130
void config_object_impl::get_data_raw ( stream_writer p_stream,
abort_callback p_abort 
)
inlineprivatevirtual

Retrieves state of the variable. Called only from main thread, when writing configuration file.

Parameters
p_streamStream receiving state of the variable.

Implements cfg_var_writer.

Definition at line 42 of file config_object_impl.h.

42 {get_data(p_stream,p_abort);}
void get_data(stream_writer *p_stream, abort_callback &p_abort) const
GUID config_object_impl::get_guid ( ) const
inlinevirtual

Implements config_object.

Definition at line 34 of file config_object_impl.h.

34 {return cfg_var::get_guid();}
GUID get_guid() const
Definition: cfg_var.h:59
void config_object_impl::set_data ( stream_reader p_stream,
abort_callback p_abort,
bool  p_notify 
)
virtual

Implements config_object.

Definition at line 187 of file config_object.cpp.

187  {
189 
190  {
191  insync(m_sync);
192  m_data.set_size(0);
193  enum {delta = 1024};
194  t_uint8 buffer[delta];
195  for(;;)
196  {
197  t_size delta_done = p_stream->read(buffer,delta,p_abort);
198 
199  if (delta_done > 0)
200  {
201  m_data.append_fromptr(buffer,delta_done);
202  }
203 
204  if (delta_done != delta) break;
205  }
206  }
207 
208  if (p_notify) config_object_notify_manager::g_on_changed(this);
209 }
critical_section m_sync
void ensure_main_thread()
Triggers a bug check if the calling thread is not the main app thread.
static void g_on_changed(const service_ptr_t< config_object > &p_object)
uint8_t t_uint8
Definition: int_types.h:9
size_t t_size
Definition: int_types.h:48
void set_size(t_size p_size)
Definition: array.h:104
void append_fromptr(const t_append *p_buffer, t_size p_count)
Warning: buffer pointer must not point to buffer allocated by this array (fixme). ...
Definition: array.h:167
pfc::array_t< t_uint8 > m_data
void config_object_impl::set_data_raw ( stream_reader p_stream,
t_size  p_sizehint,
abort_callback p_abort 
)
inlineprivatevirtual

Sets state of the variable. Called only from main thread, when reading configuration file.

Parameters
p_streamStream containing new state of the variable.
p_sizehintNumber of bytes contained in the stream; reading past p_sizehint bytes will fail (EOF).

Implements cfg_var_reader.

Definition at line 43 of file config_object_impl.h.

43 {set_data(p_stream,p_abort,false);}
void set_data(stream_reader *p_stream, abort_callback &p_abort, bool p_notify)

Field Documentation

pfc::array_t<t_uint8> config_object_impl::m_data
private

Definition at line 46 of file config_object_impl.h.

critical_section config_object_impl::m_sync
mutableprivate

Definition at line 45 of file config_object_impl.h.


The documentation for this class was generated from the following files: