LogBookPerson

Name

LogBookPerson -- Encapsulate a person registered in a logbook.

Synopsis


#include <LogBookPerson.h>

class LogBookPerson
{

public:
    LogBookPerson(CSqlite& db, int id);  
    LogBookPerson(const LogBookPerson& rhs);
public:
    LogBookPerson& operator=(const LogBookPerson& rhs);
    int operator==(const LogBookPerson& rhs) const;
    int operator!=(const LogBookPerson& rhs) const;
    
    const char* lastName() const;
    const char* firstName() const;
    const char* salutation() const;
    int         id() const;
    
    static LogBookPerson* create(
        CSqlite& db,
        const char* lastName, const char* firstName, const char* salutation
    );
    static std::vector<LogBookPerson*> find(CSqlite& db, const char* where=nullptr);
    static std::vector<LogBookPerson*> list(CSqlite& db);
};
      

... -I$DAQINC -L$DAQLIB -lLogbook -Wl,-rpath=$DAQLIB

DESCRIPTION

The LogBookPerson class encapsulates two use cases. First it provides an encapsulation of a person that has been registered in the logbook. Second, it hides operations on persons (creation, retrieval etc.) from the LogBook API class.

As such, the documentation of the public methods in the section that follows (METHODS) will indicate methods that are not intended for actual client use but are intended for use by the LogBook class. These methods can also be used in special applications that may need to use the lower levels of the API for unanticipated purposes.

METHODS

Before describing the full set of methods for LogBookPerson just a note that copy construction, equality/inequalty comparison and assignment are fully supported by this class and the methods needed to support that need not be described.

LogBookPerson(CSqlite& db, int id);

The constructor, while public is not intended for general use. It is used to construct an encapsulation of a person from an Sqlite++ database handle db reference and the primary key of the person. This is the constructor, used for example. by LogBook::getPerson.

const const char* lastName();

Returns the last name of the person whom this object encapsulates.

const const char* firstName();

Returns the first name of the person whom this object encapsulates

const const char* salutation();

Returns the salution of the person whom this object encapsulates. Note that an empty string is used for a person who does not have a salutation so client code does not need to worry about this being a nullptr.

const int id();

Returns the primary key of the person whom this object encapsulates. The primary key is a unique integer that's assigned each person.

static LogBookPerson* create(CSqlite& db, const char* lastName, const char* firsName, const char* salutation);

Not intended for general use, this method creates a new person entry in the database. This is used by e.g. LogBook::addPerson.

db is a reference to an Sqlite++ database connection object and lastName, firstName and salutation provide the data from which the person is created. Once created, a pointer to a dynamically constructed encapsulation is returned to the caller.

While the saluation of a person is considered optional, use a pointer to an empty string if one is not desired.

static std::vector<LogBookPerson*> find(CSqlite& db, const char* wherenullptr );

This is not intended for general use. It is used by LogBook::findPeople. The method returns a vector pointers to dynamically allocated LogBookPerson objects that match the SQL where clause in where. This claus should omit the keyword WHERE. See Logbook Schema for the fields that can be used in where.

If where is a null pointer, as it is by default, no filtering is done and the result is functionally equivalent to that returned by list below.

static std::vector<LogBookPerson*> list(CSqlite& db);

Returns a list of pointers to dynamically allocated LogBookPerson objects that encapsulate all people that have been registered in the logbook database.