Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | Friends | List of all members
YFiles Class Reference

#include <yocto_files.h>

Inheritance diagram for YFiles:
Inheritance graph
[legend]

Public Member Functions

virtual int _invokeValueCallback (string value)
 
virtual string download (string pathname)
 
virtual bool fileExist (string filename)
 
int filesCount (void)
 
virtual int format_fs (void)
 
int freeSpace (void)
 
int get_filesCount (void)
 
int get_freeSpace (void)
 
virtual vector< YFileRecordget_list (string pattern)
 
YFilesnext (void)
 
YFilesnextFiles (void)
 
virtual int registerValueCallback (YFilesValueCallback callback)
 
virtual int remove (string pathname)
 
virtual string sendCommand (string command)
 
virtual int upload (string pathname, string content)
 
 ~YFiles ()
 
- Public Member Functions inherited from YFunction
void _clearDataStreamCache ()
 
string _decode_json_string (const string &json)
 
string _download (const string &url)
 
YDataStream_findDataStream (YDataSet &dataset, const string &def)
 
string _get_json_path (const string &json, const string &path)
 
vector< string > _json_get_array (const string &json)
 
string _json_get_key (const string &json, const string &data)
 
string _json_get_string (const string &json)
 
int _parseEx (yJsonStateMachine &j)
 
virtual int _parserHelper (void)
 
string _parseString (yJsonStateMachine &j)
 
string _request (const string &request)
 
string _requestEx (int tcpchan, const string &request, yapiRequestProgressCallback callback, void *context)
 
void _throw (YRETCODE errType, string errMsg)
 
YRETCODE _upload (const string &path, const string &content)
 
YRETCODE _uploadWithProgress (const string &path, const string &content, yapiRequestProgressCallback callback, void *context)
 
string advertisedValue (void)
 
void clearCache ()
 
string describe (void)
 
string errMessage (void)
 
string errorMessage (void)
 
YRETCODE errorType (void)
 
YRETCODE errType (void)
 
YFUN_DESCR functionDescriptor (void)
 
string get_advertisedValue (void)
 
string get_errorMessage (void)
 
YRETCODE get_errorType (void)
 
virtual string get_friendlyName (void)
 
YFUN_DESCR get_functionDescriptor (void)
 
string get_functionId (void)
 
string get_hardwareId (void)
 
string get_hubSerial ()
 
string get_logicalName (void)
 
YModuleget_module (void)
 
void * get_userData (void)
 
bool isOnline (void)
 
YRETCODE load (int msValidity)
 
virtual string loadAttribute (string attrName)
 
string logicalName (void)
 
YModulemodule (void)
 
virtual int muteValueCallbacks (void)
 
YFunctionnext (void)
 
YFunctionnextFunction (void)
 
virtual int registerValueCallback (YFunctionValueCallback callback)
 
int set_advertisedValue (const string &newval)
 
int set_logicalName (const string &newval)
 
void set_userData (void *data)
 
int setAdvertisedValue (const string &newval)
 
int setLogicalName (const string &newval)
 
void setUserData (void *data)
 
virtual int unmuteValueCallbacks (void)
 
void * userData (void)
 
virtual ~YFunction ()
 

Static Public Member Functions

static YFilesFind (string func)
 
static YFilesFindFiles (string func)
 
static YFilesFirst (void)
 
static YFilesFirstFiles (void)
 
- Static Public Member Functions inherited from YFunction
static void _ClearCache (void)
 
static YFunctionFind (string func)
 
static YFunctionFindFunction (string func)
 
static YFunctionFirst (void)
 
static YFunctionFirstFunction (void)
 

Static Public Attributes

static const int FILESCOUNT_INVALID = YAPI_INVALID_UINT
 
static const int FREESPACE_INVALID = YAPI_INVALID_UINT
 
- Static Public Attributes inherited from YFunction
static const string ADVERTISEDVALUE_INVALID = YAPI_INVALID_STRING
 
static const string FRIENDLYNAME_INVALID = YAPI_INVALID_STRING
 
static const YFUN_DESCR FUNCTIONDESCRIPTOR_INVALID = Y_FUNCTIONDESCRIPTOR_INVALID
 
static const string FUNCTIONID_INVALID = YAPI_INVALID_STRING
 
static const string HARDWAREID_INVALID = YAPI_INVALID_STRING
 
static const string LOGICALNAME_INVALID = YAPI_INVALID_STRING
 

Private Member Functions

virtual int _parseAttr (YJSONObject *json_val)
 
 YFiles (const string &func)
 

Private Attributes

int _filesCount
 
int _freeSpace
 
YFilesValueCallback _valueCallbackFiles
 

Friends

YFilesyFindFiles (const string &func)
 
YFilesyFirstFiles (void)
 

Additional Inherited Members

- Protected Member Functions inherited from YFunction
YRETCODE _buildSetRequest (const string &changeattr, const string *changeval, string &request, string &errmsg)
 
string _escapeAttr (const string &changeval)
 
YRETCODE _getDescriptor (YFUN_DESCR &fundescr, string &errMsg)
 
YRETCODE _getDevice (YDevice *&dev, string &errMsg)
 
YRETCODE _load_unsafe (int msValidity)
 
YRETCODE _nextFunction (string &hwId)
 
int _parse (YJSONObject *j)
 
YRETCODE _setAttr (string attrname, string newvalue)
 
 YFunction (const string &func)
 
- Static Protected Member Functions inherited from YFunction
static void _AddToCache (const string &classname, const string &func, YFunction *obj)
 
static YFunction_FindFromCache (const string &classname, const string &func)
 
static void _UpdateTimedReportCallbackList (YFunction *func, bool add)
 
static void _UpdateValueCallbackList (YFunction *func, bool add)
 
- Protected Attributes inherited from YFunction
string _advertisedValue
 
u64 _cacheExpiration
 
string _className
 
std::map< string, YDataStream * > _dataStreams
 
string _func
 
YFUN_DESCR _fundescr
 
string _funId
 
string _hwId
 
string _lastErrorMsg
 
YRETCODE _lastErrorType
 
string _logicalName
 
string _serial
 
yCRITICAL_SECTION _this_cs
 
void * _userData
 
YFunctionValueCallback _valueCallbackFunction
 
- Static Protected Attributes inherited from YFunction
static std::map< string, YFunction * > _cache
 

Detailed Description

YFiles Class: Files function interface

The filesystem interface makes it possible to store files on some devices, for instance to design a custom web UI (for networked devices) or to add fonts (on display devices).

Definition at line 115 of file yocto_files.h.

Constructor & Destructor Documentation

YFiles::YFiles ( const string &  func)
private

Definition at line 115 of file yocto_files.cpp.

YFiles::~YFiles ( )

Definition at line 125 of file yocto_files.cpp.

Member Function Documentation

int YFiles::_invokeValueCallback ( string  value)
virtual

Reimplemented from YFunction.

Definition at line 282 of file yocto_files.cpp.

int YFiles::_parseAttr ( YJSONObject json_val)
privatevirtual

Reimplemented from YFunction.

Definition at line 134 of file yocto_files.cpp.

string YFiles::download ( string  pathname)
virtual

Downloads the requested file and returns a binary buffer with its content.

Parameters
pathname: path and name of the file to download
Returns
a binary buffer with the file content

On failure, throws an exception or returns an empty content.

Definition at line 381 of file yocto_files.cpp.

bool YFiles::fileExist ( string  filename)
virtual

Test if a file exist on the filesystem of the module.

Parameters
filename: the file name to test.
Returns
a true if the file existe, false ortherwise.

On failure, throws an exception.

Definition at line 357 of file yocto_files.cpp.

int YFiles::filesCount ( void  )
inline

Definition at line 155 of file yocto_files.h.

static YFiles* YFiles::Find ( string  func)
inlinestatic

Definition at line 294 of file yocto_files.h.

YFiles * YFiles::FindFiles ( string  func)
static

Retrieves a filesystem for a given identifier. The identifier can be specified using several formats:

  • FunctionLogicalName
  • ModuleSerialNumber.FunctionIdentifier
  • ModuleSerialNumber.FunctionLogicalName
  • ModuleLogicalName.FunctionIdentifier
  • ModuleLogicalName.FunctionLogicalName

This function does not require that the filesystem is online at the time it is invoked. The returned object is nevertheless valid. Use the method YFiles.isOnline() to test if the filesystem is indeed online at a given time. In case of ambiguity when looking for a filesystem by logical name, no error is notified: the first instance found is returned. The search is performed first by hardware name, then by logical name.

If a call to this object's is_online() method returns FALSE although you are certain that the matching device is plugged, make sure that you did call registerHub() at application initialization time.

Parameters
func: a string that uniquely characterizes the filesystem
Returns
a YFiles object allowing you to drive the filesystem.

Definition at line 231 of file yocto_files.cpp.

static YFiles* YFiles::First ( void  )
inlinestatic

Definition at line 318 of file yocto_files.h.

YFiles * YFiles::FirstFiles ( void  )
static

Starts the enumeration of filesystems currently accessible. Use the method YFiles.nextFiles() to iterate on next filesystems.

Returns
a pointer to a YFiles object, corresponding to the first filesystem currently online, or a NULL pointer if there are none.

Definition at line 439 of file yocto_files.cpp.

int YFiles::format_fs ( void  )
virtual

Reinitialize the filesystem to its clean, unfragmented, empty state. All files previously uploaded are permanently lost.

Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 308 of file yocto_files.cpp.

int YFiles::freeSpace ( void  )
inline

Definition at line 167 of file yocto_files.h.

int YFiles::get_filesCount ( void  )

Returns the number of files currently loaded in the filesystem.

Returns
an integer corresponding to the number of files currently loaded in the filesystem

On failure, throws an exception or returns Y_FILESCOUNT_INVALID.

Definition at line 153 of file yocto_files.cpp.

int YFiles::get_freeSpace ( void  )

Returns the free space for uploading new files to the filesystem, in bytes.

Returns
an integer corresponding to the free space for uploading new files to the filesystem, in bytes

On failure, throws an exception or returns Y_FREESPACE_INVALID.

Definition at line 182 of file yocto_files.cpp.

vector< YFileRecord > YFiles::get_list ( string  pattern)
virtual

Returns a list of YFileRecord objects that describe files currently loaded in the filesystem.

Parameters
pattern: an optional filter pattern, using star and question marks as wildcards. When an empty pattern is provided, all file records are returned.
Returns
a list of YFileRecord objects, containing the file path and name, byte size and 32-bit CRC of the file content.

On failure, throws an exception or returns an empty list.

Definition at line 334 of file yocto_files.cpp.

YFiles* YFiles::next ( void  )
inline

Definition at line 305 of file yocto_files.h.

YFiles * YFiles::nextFiles ( void  )

Continues the enumeration of filesystems started using yFirstFiles().

Returns
a pointer to a YFiles object, corresponding to a filesystem currently online, or a NULL pointer if there are no more filesystems to enumerate.

Definition at line 429 of file yocto_files.cpp.

int YFiles::registerValueCallback ( YFilesValueCallback  callback)
virtual

Registers the callback function that is invoked on every change of advertised value. The callback is invoked only during the execution of ySleep or yHandleEvents. This provides control over the time when the callback is triggered. For good responsiveness, remember to call one of these two functions periodically. To unregister a callback, pass a NULL pointer as argument.

Parameters
callback: the callback function to call, or a NULL pointer. The callback function should take two arguments: the function object of which the value has changed, and the character string describing the new advertised value.

Definition at line 263 of file yocto_files.cpp.

int YFiles::remove ( string  pathname)
virtual

Deletes a file, given by its full path name, from the filesystem. Because of filesystem fragmentation, deleting a file may not always free up the whole space used by the file. However, rewriting a file with the same path name will always reuse any space not freed previously. If you need to ensure that no space is taken by previously deleted files, you can use format_fs to fully reinitialize the filesystem.

Parameters
pathname: path and name of the file to remove.
Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 416 of file yocto_files.cpp.

string YFiles::sendCommand ( string  command)
virtual

Definition at line 292 of file yocto_files.cpp.

int YFiles::upload ( string  pathname,
string  content 
)
virtual

Uploads a file to the filesystem, to the specified full path name. If a file already exists with the same path name, its content is overwritten.

Parameters
pathname: path and name of the new file to create
content: binary buffer with the content to set
Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 397 of file yocto_files.cpp.

Friends And Related Function Documentation

YFiles* yFindFiles ( const string &  func)
friend

Retrieves a filesystem for a given identifier. The identifier can be specified using several formats:

  • FunctionLogicalName
  • ModuleSerialNumber.FunctionIdentifier
  • ModuleSerialNumber.FunctionLogicalName
  • ModuleLogicalName.FunctionIdentifier
  • ModuleLogicalName.FunctionLogicalName

This function does not require that the filesystem is online at the time it is invoked. The returned object is nevertheless valid. Use the method YFiles.isOnline() to test if the filesystem is indeed online at a given time. In case of ambiguity when looking for a filesystem by logical name, no error is notified: the first instance found is returned. The search is performed first by hardware name, then by logical name.

If a call to this object's is_online() method returns FALSE although you are certain that the matching device is plugged, make sure that you did call registerHub() at application initialization time.

Parameters
func: a string that uniquely characterizes the filesystem
Returns
a YFiles object allowing you to drive the filesystem.

Definition at line 355 of file yocto_files.h.

YFiles* yFirstFiles ( void  )
friend

Starts the enumeration of filesystems currently accessible. Use the method YFiles.nextFiles() to iterate on next filesystems.

Returns
a pointer to a YFiles object, corresponding to the first filesystem currently online, or a NULL pointer if there are none.

Definition at line 366 of file yocto_files.h.

Member Data Documentation

int YFiles::_filesCount
private

Definition at line 122 of file yocto_files.h.

int YFiles::_freeSpace
private

Definition at line 123 of file yocto_files.h.

YFilesValueCallback YFiles::_valueCallbackFiles
private

Definition at line 124 of file yocto_files.h.

const int YFiles::FILESCOUNT_INVALID = YAPI_INVALID_UINT
static

Definition at line 143 of file yocto_files.h.

const int YFiles::FREESPACE_INVALID = YAPI_INVALID_UINT
static

Definition at line 144 of file yocto_files.h.


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


yoctopuce_altimeter
Author(s): Anja Sheppard
autogenerated on Mon Jun 10 2019 15:49:13