Copyright © 1997 The California Institute of Technology
All rights reserved.

Class: FeiProfile


A profile object is created by an Fei object for every file is handles. A pointer to a file's profile record is returned by Fei::results.

When you first look at a file's profile record, you should check the status with the getStatus method. If the value is anything but FEI_OK, there's an error associated with the file or its transmission by FEI. A profile record contains several pieces of information that may be of of interest. Each is accessed by one of FeiProfile's get... methods. See the following for more information:

Two special get... methods return the address of a buffer and the buffers size if the file's content are written to memory and not to disk. They are:

The method getStatus has already been mentioned. If an error occurs, you can retrieve the text of the error message with the method getMsg.

The method getProfileString returns a formated string with the following syntax:

	fileType/fileName [, timeStamp] [, size] [, crc]
Use this method as a convient way to supply information about a file to the user.

Profile objects are returned in an Fei queue. These records are not deleted by Fei. It's you responsibility to retrieve them and then to delete them when you're done with them. Note: always use "delete", and not "free" to deallocate memory associated with a profile object. You can retain some of the information in a profile record before deleting it by using FEI_RETAIN as the argument to specified get... methods. For example, to retain the buffer associated with a file's contents returned to memory, you would use the following command:

   void *addr = profile->getAddr (FEI_RETAIN);
Then, after the profile object is deleted:
   delete profile;
you can still access the content buffer. (If you're keeping the content buffer around, you should also get the buffer's size with "getSize()'.)

For more information on the class, see the header file: FeiProfile.h


FeiProfile::~FeiProfile ()

Deallocate any memory used for strings.


inline void *FeiProfile::getAddress (bool retain)

Returns the starting address of a buffer containing the files contents. The size of the buffer can be obtained using the method getSize. Only meaningful if the file's contents are returned in memory.

If the optional argument retain is set to FEI_RETAIN, then the memory allocated for this variable will not be deleted when you delete the profile record. It is then your responsibility to deallocate the memory when you no longer need it. Note: use delete, not free, to deallocate the memory.


inline char FeiProfile::getCommand ()

Returns the command character for the transaction that produced this profile object. For example: a, g, s, y, etc.


inline const char *FeiProfile::getComment (bool retain)

Returns the comment associated with a file. Only valid for get, subscribe and notify operations where the comment exists in the file's record in the FEI database table files.

If the optional argument retain is set to retain, then the memory allocated for this variable will not be deleted when you delete the profile record. It is then your responsibility to deallocate the memory when you no longer need it. Note: use delete, not free, to deallocate the memory.


inline const char *FeiProfile::getContentType (bool retain)

Returns the file's content type: eg, image, text, edr, etc.

If the optional argument retain is set to FEI_RETAIN, then the memory allocated for this variable will not be deleted when you delete the profile record. It is then your responsibility to deallocate the memory when you no longer need it. Note: use delete, not free, to deallocate the memory.


inline const char *FeiProfile::getCrc (bool retain)

Returns the cyclic redundancy check (crc) value of the file associated with the profile object.

If the optional argument retain is set to FEI_RETAIN, then the memory allocated for this variable will not be deleted when you delete the profile record. It is then your responsibility to deallocate the memory when you no longer need it. Note: use delete, not free, to deallocate the memory.


inline const char *FeiProfile::getFeiDomain (bool retain)

Returns the feiDomain name. Only meaningful when the profile object reads session state information from a restart file. Used when restarting subscription or restart. Not for general use.

If the optional argument retain is set to FEI_RETAIN, then the memory allocated for this variable will not be deleted when you delete the profile record. It is then your responsibility to deallocate the memory when you no longer need it. Note: use delete, not free, to deallocate the memory.


inline const char *FeiProfile::getFileName (bool retain)

Returns the file name of the file associated with the profile object.

If the optional argument retain is set to FEI_RETAIN, then the memory allocated for this variable will not be deleted when you delete the profile record. It is then your responsibility to deallocate the memory when you no longer need it. Note: use delete, not free, to deallocate the memory.


inline const char *FeiProfile::getFileType (bool retain)

Returns the file type of the file associated with the profile object.

If the optional argument retain is set to FEI_RETAIN, then the memory allocated for this variable will not be deleted when you delete the profile record. It is then your responsibility to deallocate the memory when you no longer need it. Note: use delete, not free, to deallocate the memory.


inline const char *FeiProfile::getLocalPath (bool retain)

Returns the local path of the file associated with the profile object.

If the optional argument retain is set to FEI_RETAIN, then the memory allocated for this variable will not be deleted when you delete the profile record. It is then your responsibility to deallocate the memory when you no longer need it. Note: use delete, not free, to deallocate the memory.


inline char *FeiProfile::getMsg ()

If the status value, see method getStatus, is not FEI_OK, then the message string associated with any error is returned by this method.


inline const char *FeiProfile::getNewFileName (bool retain)

Returns the new file name used with file that has been renamed.

If the optional argument retain is set to FEI_RETAIN, then the memory allocated for this variable will not be deleted when you delete the profile record. It is then your responsibility to deallocate the memory when you no longer need it. Note: use delete, not free, to deallocate the memory.


void FeiProfile::getProfile (
char *cmd,
const char *feiDomain,
const char *fileType,
const char *fileName,
const char *localPath,
const char *timeStamp,
unsigned int *size,
const char *contentType,
const char *aCrc,
const char *comment)

Returns references or values to all profile items with a single call. For individual returns, see the inline methods get...


const char* FeiProfile::getProfileString ()

Returns profile information as a string. The format of the string is:

     [] 

The size of the file is given in bytes. If the crc value is not defined it's not included in the fromatted string. The values in the string are returned in fixed length fields so they line-up in columns.

Returns the formated string for add, replace, get, subscribe, notify, live list and list commands. Otherwise it returns the NULL string. The space allocated for this string should not be directly deleted by you. It's deleted by FeiProfile code when the profile is deleted.


inline size_t FeiProfile::getSize ()

Returns the size of the buffer referenced by address. Only meaningful if the file's contents are returned in memory. See getAddress.


inline int FeiProfile::getStatus ()

Returns the profile's status value. If there is no error associated with the file's transmission, the value returned is FEI_OK. Otherwise, one of the following values is returned: FEI_INFO, FEI_WARN, FEI_ERROR, FEI_FATAL. See FeiMsg for more information about these values.


inline const char *FeiProfile::getTimeStamp (bool retain)

Returns the profile's FEI file modification date and time as a string value.

If the optional argument retain is set to FEI_RETAIN, then the memory allocated for this variable will not be deleted when you delete the profile record. It is then your responsibility to deallocate the memory when you no longer need it. Note: use delete, not free, to deallocate the memory.


bool FeiProfile::isOption (int option)

isOption (option) returns true if the option specified is set.


int FeiProfile::saveRecordTo (FILE *fp)

Write contents of the profile record to the file who's file pointer is supplied. This profile record writes over any existing in the file. Need to acquire a lock before writting a new record. Don't want to step on another writter or reader.


const char *FeiProfile::setFileName (const char *name)

setFileName ()


int FeiProfile::verifyCommand ()

Make sure profiles created as a command are valid. Sets status, as well as any message describing an invalid command into the profile. This function does not check for every possible error. For now, we just make sure _localPath is a directory, and that we can write into it. We don't verify everything, since the purpose of this command is to avoid bothering the server on badly formed commands. But, it is expensive. So, for example, we don't check the _feiDomain, since, we can't bother the server on that one if we continue, so, just let that fail when we try to get to the domain (restart). We don't check for the existence of files to send since NetClient does not ship the command to the server if it can't open the file, so why pay to check this now? The only one I can see (so far) catching early is the localPath for directories. Subscription would fail when a file comes in, but we'd like to fail the subscription immediately on this error. And we may as well do this on get. In the spirit of optimism, I don't think we should check the add file cases. Just let them fail at execution time, since we don't ship those commands to the server anyway. So in no case, even with this minimal (and cheap) check that we'll send a command to the server if there is no chance it can be completed successfully.