Class FSNode

Index Home MAE > MAE Architecture > MAE Data Types > Class Index > Class FSNode

Summary
Public Methods
FSNode(id)
FSNode(data)
FSNode(text)
inline string toString() const
void clear()
inline bool valid() const
inline DbRecNum getId() const
inline DbRecNum getParentId() const
inline bool isDirectory() const
inline const string& getName() const
inline string getSpoke() const
inline bool onRoot()
inline const string& getOSFilename() const
inline const string& getPath() const
inline DbRecNum getResourceId() const
inline const time_t& getAccessTime() const
inline const time_t& getModTime() const
inline DbRecNum getOwner() const
inline const string& getAccess() const
string get(key) const
inline void setId(newId)
inline FSNode& setParentId(newparentId)
inline FSNode& setDirectory(newisDir)
inline FSNode& setName(newname)
inline FSNode& setSpoke(newspoke)
inline FSNode& setOSFilename(newfilename)
inline FSNode& setPath(newpath)
inline FSNode& setResourceId(newresourceId)
inline FSNode& setAccessTime(newatime)
inline FSNode& setModTime(newmtime)
inline FSNode& setOwner(newowner)
inline FSNode& setAccess(newaccess)
FSNode& set(data)
bool set(key, value)
static DbRecList find(criteria, sortby)
static DbRecList find(criteria, sortby)
static DbRecList getAllIds()
static DbRecList getSpokeIds(spoke)
HashArray toHashArray(forDB) const
inline XMLData toXML(forDB) const
DbRecNum save()
DbRecNum append()
bool deleteRecord()
static DbRecNum append(values)
static vector getHostFsNodes(fspath)
Protected Methods
bool load(id)
Private Properties
Private Methods
static bool initdb()
See Also

#include <FSNode.h >

Summary

Class to manage MAE virtual file system nodes.

Public Methods

FSNode(id)

DbRecNum id

db table record id; 0 for empty record

Default value: 0


Constructor with optional db table record id.

FSNode(data)

const HashArray& data

key-value pairs with property names as keys


Constructor with input from HashArray.

FSNode(text)

const string& text

the key/value pairs as HashArray text


Construct a FSNode from a string (output of toString())

inline string toString() const

Convert this instance to a string, which can later reconstruct this instance

Return value: a text string

void clear()

Reset/Clear the contents of this instance

inline bool valid() const

Determine if this instance has valid data or no.

Return value: true if valid; flase if not valid

inline DbRecNum getId() const

Get the value of FSNode table id.

Return value: the value of id

inline DbRecNum getParentId() const

Get the value of Parent directory node in FSNode.

Return value: the value of parentId

inline bool isDirectory() const

Get the value of Flag: true if this node is a directory; false otherwise.

Return value: the value of isDir

inline const string& getName() const

Get the value of Name of this node (without path).

Return value: the value of name

inline string getSpoke() const

Get the value of Name of the spoke where the resource resides.

Return value: the value of spoke

inline bool onRoot()

Determine if this node is hosted by the root server, not a spoke

Return value: true if hosted by root server

inline const string& getOSFilename() const

Get the value of Actual filename in spoke's filesystem (if it's an acutal file)

Return value: the value of osfilename

inline const string& getPath() const

Get the value of For a directory, it's MAE path (includes name).

Return value: the value of path

inline DbRecNum getResourceId() const

Get the value of Id from IORegistry table; 0 if not in registry.

Return value: the value of resourceId

inline const time_t& getAccessTime() const

Get the value of Last access time.

Return value: the value of atime

inline const time_t& getModTime() const

Get the value of Last modification time.

Return value: the value of mtime

inline DbRecNum getOwner() const

Get the value of Resource owner; User record id.

Return value: the value of owner

inline const string& getAccess() const

Get the value of Accessibility, e.g. r, w, rw.

Return value: the value of access

string get(key) const

string key

the propery name to get (case insensitive)


Given a FSNode single property name (key), return its value as a string.

Return value: the string equivalent of the property

inline void setId(newId)

DbRecNum newId

the new id


Set the node's id

inline FSNode& setParentId(newparentId)

DbRecNum newparentId

the new value for parentId


Set the value of Parent directory node in FSNode.

Return value: the updated instance of FSNode

inline FSNode& setDirectory(newisDir)

bool newisDir

the new value for isDir

Default value: true


Set the value of Flag: true if this node is a directory; false otherwise.

Return value: the updated instance of FSNode

inline FSNode& setName(newname)

const string& newname

the new value for name


Set the value of Name of this node (without path).

Return value: the updated instance of FSNode

inline FSNode& setSpoke(newspoke)

const string& newspoke

the new value for spoke


Set the value of Name of the spoke where the resource resides.

Return value: the updated instance of FSNode

inline FSNode& setOSFilename(newfilename)

const string& newfilename

the new value for osfilename


Set the value of Actual filename in spoke's filesystem (if it's an acutal file)

Return value: the updated instance of FSNode

inline FSNode& setPath(newpath)

const string& newpath

the new value for path


Set the value of For a directory, it's MAE path (includes name).

Return value: the updated instance of FSNode

inline FSNode& setResourceId(newresourceId)

DbRecNum newresourceId

the new value for resourceId


Set the value of Id from IORegistry table; 0 if not in registry.

Return value: the updated instance of FSNode

inline FSNode& setAccessTime(newatime)

time_t newatime

the new value for atime


Set the value of Last access time.

Return value: the updated instance of FSNode

inline FSNode& setModTime(newmtime)

time_t newmtime

the new value for mtime


Set the value of Last modification time.

Return value: the updated instance of FSNode

inline FSNode& setOwner(newowner)

DbRecNum newowner

the new value for owner


Set the value of Resource owner; User record id.

Return value: the updated instance of FSNode

inline FSNode& setAccess(newaccess)

const string& newaccess

the new value for access


Set the value of Accessibility, e.g. r, w, rw.

Return value: the updated instance of FSNode

FSNode& set(data)

const HashArray& data

the key/value pairs to set


Given a set of FSNode properties in key-value pairs, initialize this instance with them.

This is complementary to toHashArray().

Return value: the initialized instance of FSNode

bool set(key, value)

string key

the propery name to set (case insensitive)

const string& value

a string equivalent to assign (it will be converted)


Given a FSNode single property name (key) and a string value, assign the value to the property.

Return value: true upon success, false on failure (like invalid property name)

static DbRecList find(criteria, sortby)

const HashArray& criteria

key/value (field/value) pairs to find

const string& sortby

sort the resulting list by this field name

Default value: ""


Given field/value criteria, find matching record ids.

Return value: list of FSNode record ids matching the criteria

static DbRecList find(criteria, sortby)

const string& criteria

an expression of fields, comparators, parenthesis and logic ops

const string& sortby

sort the resulting list by this field name

Default value: ""


Given criteria expression, find matching record ids.

Return value: list of FSNode record ids matching the criteria

static DbRecList getAllIds()

Get a list of all record ids.

Return value: the list of all record ids

static DbRecList getSpokeIds(spoke)

const string& spoke

the name of the spoke


Get a list of all record ids for a specific spoke.

Return value: the list of all record ids for spoke

HashArray toHashArray(forDB) const

bool forDB

false to include Id; true to exclude Id, which is handy for sending to Datastore

Default value: false


Convert this instance's data into a HashArray.

This is the complement of set()

Return value: a HashArray of instance's properties

inline XMLData toXML(forDB) const

bool forDB

false to include Id; true to exclude Id, which is handy for sending to Datastore

Default value: false


Convert this instance's data to XML.

Return value: a XMLData of instance's properties

DbRecNum save()

Save this record to the Datastore.

If the data has not changed, it is not saved.

Return value: the Id upon success, 0 on failure

DbRecNum append()

Add a new record to the Datastore.

If the Id is set, it will be used; if 0, a new Id will be assigned.

Return value: the new record's record Id

bool deleteRecord()

Delete the record from the Datastore.

Return value: true if successfully deleted; false on error (like id==0 or DB error)

static DbRecNum append(values)

const HashArray& values

key/value pairs for field assignments


Add a new record to the Datastore.

If the Id field is set, it will be used; if 0, a new Id will be assigned.

Return value: the new record's record Id

static vector <FSNode > getHostFsNodes(fspath)

const string& fspath

the filesystem path on the current host OS


Query the host OS filesystem for files and return them as vector.

Note the vector is not setting id, parentId, spoke, path, or resourceId,

only name and isDir.

Return value: a list of nodes (files and directories)

Protected Methods

bool load(id)

DbRecNum id

the id of the record to load


Load data from the Datastore with the provided Id.

Return value: true upon success; false upon faliure

Private Properties

DbRecNum id

FSNode table id

DbRecNum parentId

Parent directory node in FSNode

bool isDir

Flag: true if this node is a directory; false otherwise

string name

Name of this node (without path)

string spoke

Name of the spoke where the resource resides

string osfilename

Actual filename in spoke's filesystem (if it's an acutal file)

string path

For a directory, it's MAE path (includes name)

DbRecNum resourceId

Id from IORegistry table; 0 if not in registry

time_t atime

Last access time

time_t mtime

Last modification time

DbRecNum owner

Resource owner; User record id

string access

Accessibility, e.g. r, w, rw

string type

Resource type

long size

Resource size in bytes, if known; -1 otherwise

bool changed

Flag: true if any data in this instance has changed

static Datastore db

Our connection to DB table data


Private Methods

static bool initdb()

Make sure we're connected to our table in the Datastore

Return value: true upon success, false upon failure

See Also

FSNode database table