Class ImageLib

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

Summary
Using ImageLib
Public Methods
ImageLib(id)
ImageLib(name, category)
ImageLib(data)
ImageLib(data)
ImageLib(p)
void clear()
inline bool valid() const
inline ImageLibId getId() const
inline string getName() const
inline string getCategory() const
inline string getType() const
inline RawData getImage() const
inline unsigned int getChecksum() const
inline int getHeight() const
inline int getWidth() const
inline DbRecNum getOwnerId() const
inline unsigned int size() const
void setId(newId)
inline void setName(newName)
inline void setCategory(newCategory)
inline void setType(newType)
inline void setImage(newImage)
inline void setChecksum(newChecksum)
inline void setHeight(newHeight)
inline void setWidth(newWidth)
inline void setOwnerId(newOwnerId)
void set(data)
inline bool operator==(other)
inline bool operator!=(other)
bool fromString(data)
string toString() const
unsigned int calcChecksum()
inline void recalcChecksum()
static string getName(id)
static bool getHeightWidth(id, height, width)
static string getType(id)
static ImageLibId find(name, category)
HashArray toHashArray(forDB) const
inline XMLData toXML(forDB) const
DbRecNum save()
Protected Methods
bool load(id)
Private Properties
Private Methods
static bool initdb()
DbRecNum append()

#include <ImageLib.h >

Summary

The ImageLib class manages stored images in the ImageLib DB table.

Using ImageLib

This class holds a reference to and then ultimately delivers the binary content of an image in the Image Library (the ImageLib table).  This class holds the image id, name, category, image type, height and width of the image.

Public Methods

ImageLib(id)

ImageLibId id

If specified, the DB record id of the image.

Default value: 0


Constructor. Existing image in DB table.

ImageLib(name, category)

const string& name

the name for the image

const string& category

the category for the image (provide by your app architect)


Constructor. Create a new image by name and category

ImageLib(data)

const string& data

a serialized ImageLib object data, represented as a string


Convert a serialized ImageLib object into the object.

ImageLib(data)

const HashArray& data

a HashArray of ImageLib data


Convert a HashArray of an ImageLib object into an object.

ImageLib(p)

const ImageLib& p

the image to copy


Copy constructor

void clear()

Reset/Clear the contents of this class

inline bool valid() const

Determine if this instance is valid data or not.

inline ImageLibId getId() const

Get the DB table record number for the image.

Return value: the record id

inline string getName() const

Get the name of the image.

Return value: the image name

inline string getCategory() const

Get the category (grouping name) for the image, e.g. icon, custom.

A category is app-specific, not system defined.

Return value: the image's category

inline string getType() const

Get the image type, e.g. gif, jpg, pdf, etc

Return value: the image type

inline RawData getImage() const

Get the data that is the image.

Return value: data for the image

inline unsigned int getChecksum() const

Get the checksum for the image

Return value: the image's checksum

inline int getHeight() const

Get the height of the image (in pixels), if known.

Return value: image height if known, otherwise 0

inline int getWidth() const

Get the width of the image (in pixels), if known.

Return value: image width if known, otherwise 0

inline DbRecNum getOwnerId() const

Get the User DB record id of the owner of the image.

Return value: the owner id

inline unsigned int size() const

Get the size of the image (in bytes).

Return value: image size

void setId(newId)

ImageLibId newId

ImageLib record id


Set the ImageLib DB record id for this image

inline void setName(newName)

const string& newName

new name for the image


Set the name for this image. A name should be unique within a category.

inline void setCategory(newCategory)

const string& newCategory

new category for the image


Set the category for this image. This is handy for grouping images.

inline void setType(newType)

const string& newType

new image type for the image, e.g. jpg, gif, pdf, etc.


Set the image type for this image.

inline void setImage(newImage)

const RawData& newImage

new image for this instance


Set the image data for this image.

inline void setChecksum(newChecksum)

unsigned int newChecksum

new checksum for the image


Set the checksum for this image.

inline void setHeight(newHeight)

int newHeight

new height for the image


Set the height for this image.

inline void setWidth(newWidth)

int newWidth

new width for the image


Set the width for this image.

inline void setOwnerId(newOwnerId)

DbRecNum newOwnerId

new User id for the image


Set the owner's User id for this image.

void set(data)

const HashArray& data

data to copy (unknown keys ignored)


Given a HashArray of properties, assign those properties into this

instance. This is the complement of toHashArray().

inline bool operator==(other)

const ImageLib& other

the other ImageLib image for comparison


Compare two images to determine if they are the same.

Return value: true if images are the same, false if they are different

inline bool operator!=(other)

const ImageLib& other

the other ImageLib image for comparison


Compare two images to determine if they are not the same

Return value: true if images are the different, false if they are same

bool fromString(data)

const string& data

a string (generated by toString())


Given a serialized ImageLib image, reconstruct this ImageLib instance to it.

Return value: true if the image was reconstructed, false if not

string toString() const

Create a serialized string of this ImageLib.

Return value: a string representation of this object

unsigned int calcChecksum()

Calculate the image's checksum

Return value: the checksum

inline void recalcChecksum()

Recalculate the image's checksum (after a new image is loaded)

static string getName(id)

ImageLibId id

the ImageLib record id to query


Query image name without pulling it into memory.

Return value: the name of the image

static bool getHeightWidth(id, height, width)

ImageLibId id

the ImageLib record id to query

int& height

(output) the height of the object (in pixels)

int& width

(output) the width of the object (in pixels)


Query image height and width without pulling it into memory.

Return value: true upon success, false upon failure (invalid id or DB issue)

static string getType(id)

ImageLibId id

the ImageLib record id to query


Query image type without pulling it into memory.

Return value: the type of the image, e.g. gif, jpg, pdf, etc

static ImageLibId find(name, category)

const string& name

the image name to find within the category

const string& category

the category to search


Given an image name and category, locate its ImageLib record id.

Return value: record id of ImageLib match, 0 if not found

HashArray toHashArray(forDB) const

bool forDB

true if data is heading to Datastore, false for other communication

Default value: false


Convert structure data to HashArray.

Return value: a HashArray with the ImageLib data

inline XMLData toXML(forDB) const

bool forDB

Default value: false


Convert structure data to XML for communication.

Return value: an XML structure of the ImageLib

DbRecNum save()

Save the record to the datastore.

Return value: 1+ upon success (the id), 0 upon failure

Protected Methods

bool load(id)

ImageLibId id

the ImageLib record id to load


Load data from db

Return value: true if loaded; false it not

Private Properties

ImageLibId id

DB record if of this image

string Name

The name of the image (unique inside category)

string Category

The category for this image

string Type

The type of image, e.g. gif, jpg, pdf, etc

RawData Image

The data of the image itself

unsigned int Checksum

The checksum for the image

int Height

The height and width of the image

int Width

The height and width of the image

DbRecNum Owner_id

The User owner of the image

bool changed

Flag: true if data was changed and needs to be saved

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

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