Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

DatabaseAccess Class Reference

The Database Access Class It is the only way to access the Matrix which is controlled by the MatrixThread. Requests to the MatrixThread are sent using the normal Buffer system. More...

#include <databaseAccess.h>

List of all members.

Public Methods

 DatabaseAccess ( int ownerSock )
 The constructor for DatabaseAccess. More...

void getAllObjects ( void )
 Request all new objects from the matrix. More...

void getObject ( int objectID )
 Requesting an Object from the Matrix. More...

void getAtom ( int atomID, int objectID, int atomType )
 Requesting an Object from the Matrix. More...

void addObject ( string objectName )
 The methods for adding Objects to the Matrix Adding an object to the matrix just using the name. More...

void addObject ( int objectID, string objectName )
 Adding an object to the matrix using a predefined ID and a name. More...

void addEntity ( string objectName )
 Adding an entity to the matrix using the name very similar to addObject, but it invokes the creation of an entity, not an object. More...

void addAtom ( int objectID, int atomType, string str )
 Adding an Binary- or String-Atom to an Object (and the Matrix). More...

void addAtom ( int ojbectID, int atomType, long number )
 Adding a Long-Atom to an Object (and the Matrix). More...

void addAtom ( int atomID, int objectID, int atomType, string str )
 Adding an existing Binary- or String-Atom to an Object (and the Matrix). More...

void addAtom ( int atomID, int ojbectID, int atomType, long number )
 Adding an existing Long-Atom to an Object (and the Matrix). More...

void addReason ( int objectIDa, int objectIDb, int reasonType )
 Adding a link between two objects (with reason). More...

void removeReason ( int objectIDa, int objectIDb, int reasonType )
 Removes a link between two objects (with reason). More...


Private Attributes

int ownerSocket
 defines the owner. More...

BufferdataBaseIn
 The Buffer the MatrixThread reads from. More...

timeval myTimeStamp
 used to remember when the last update was. More...


Detailed Description

The Database Access Class It is the only way to access the Matrix which is controlled by the MatrixThread. Requests to the MatrixThread are sent using the normal Buffer system.

Author(s):
xandi
Version:
0.1
Date:
020400
Bugs and limitations:
none known

Definition at line 29 of file databaseAccess.h.

00030 {
00031     private:
00032         int     ownerSocket; 
00033         Buffer* dataBaseIn; 
00034         timeval myTimeStamp; 
00035 
00036     public:
00037 
00039 
00042         DatabaseAccess ( int ownerSock );
00043 
00045 
00048         void getAllObjects ( void );
00049 
00051 
00054         void getObject ( int objectID );
00056 
00061         void getAtom   ( int atomID, int objectID, int atomType );
00062 
00065 
00068         void addObject ( string objectName );
00070 
00075         void addObject ( int objectID, string objectName );
00077 
00081         void addEntity ( string objectName );
00082 
00084 
00089         void addAtom ( int objectID, int atomType, string str );
00091 
00096         void addAtom ( int ojbectID, int atomType, long number );
00097 
00099 
00106         void addAtom ( int atomID, int objectID, int atomType, string str );
00108 
00115         void addAtom ( int atomID, int ojbectID, int atomType, long number );
00116 
00118 
00123         void addReason ( int objectIDa, int objectIDb, int reasonType );
00125 
00130         void removeReason ( int objectIDa, int objectIDb, int reasonType );
00131 
00132 
00133     }

Constructor & Destructor Documentation

DatabaseAccess::DatabaseAccess ( int ownerSock)

The constructor for DatabaseAccess.

Parameters:
ownerSock   this number identifies the owner of that class and is written into the packets to let the matrixThread know where the package comes from.

Definition at line 54 of file databaseAccess.cpp.

00055 {
00056     dataBaseIn  = matrixBufIn;
00057     ownerSocket = ownerSock;
00058     myTimeStamp.tv_sec   = 0;
00059     myTimeStamp.tv_usec  = 0;
00060     }

Member Function Documentation

void DatabaseAccess::addAtom ( int atomID,
int ojbectID,
int atomType,
long number)

Adding an existing Long-Atom to an Object (and the Matrix).

Parameters:
atomID   the ID the Atom shall have
objectID   the object the Atom shall be attached to
atomType   defines the type of the atom (Name, Socket, 3D-Position, Graphical Description...)
number   the content of the atom
Warning:
This is just possible on client-side!

Definition at line 299 of file databaseAccess.cpp.

00300 {
00301     packet* pak;
00302     pak = new packet;
00303 
00304     pak->h.from = ownerSocket;
00305 
00306     pak->h.header[0] = ODB_ADD_ATOM;
00307     pak->h.header[2] = objectID;
00308     pak->h.header[3] = atomType;
00309     pak->h.header[4] = atomID;
00310     pak->data = str;
00311 
00312     #ifdef DEBUG
00313     fprintf(stderr,"[coT(%d).addAtom (int,int,int,string)] - %d,%d,%d,%s\n",ownerSocket,atomID,objectID,atomType,str.c_str());
00314     #endif
00315 
00316     dataBaseIn->write ( pak );
00317     }

void DatabaseAccess::addAtom ( int atomID,
int ojbectID,
int atomType,
string str)

Adding an existing Binary- or String-Atom to an Object (and the Matrix).

Parameters:
atomID   the ID the Atom shall have
objectID   the object the Atom shall be attached to
atomType   defines the type of the atom (Name, Socket, 3D-Position, Graphical Description...)
str   the content of the atom (might be binary or text)
Warning:
This is just possible on client-side!

Definition at line 299 of file databaseAccess.cpp.

00300 {
00301     packet* pak;
00302     pak = new packet;
00303 
00304     pak->h.from = ownerSocket;
00305 
00306     pak->h.header[0] = ODB_ADD_ATOM;
00307     pak->h.header[2] = objectID;
00308     pak->h.header[3] = atomType;
00309     pak->h.header[4] = atomID;
00310     pak->data = str;
00311 
00312     #ifdef DEBUG
00313     fprintf(stderr,"[coT(%d).addAtom (int,int,int,string)] - %d,%d,%d,%s\n",ownerSocket,atomID,objectID,atomType,str.c_str());
00314     #endif
00315 
00316     dataBaseIn->write ( pak );
00317     }

void DatabaseAccess::addAtom ( int ojbectID,
int atomType,
long number)

Adding a Long-Atom to an Object (and the Matrix).

Parameters:
objectID   the object the Atom shall be attached to
atomType   defines the type of the atom (Name, Socket, 3D-Position, Graphical Description...)
number   the content of the atom

Definition at line 227 of file databaseAccess.cpp.

00228 {
00229     packet* pak;
00230     pak = new packet;
00231 
00232     pak->h.from = ownerSocket;
00233 
00234     pak->h.header[0] = ODB_ADD_ATOM;
00235     pak->h.header[2] = objectID;
00236     pak->h.header[3] = atomType;
00237     pak->h.header[4] = -1;
00238     pak->data = str;
00239 
00240     #ifdef DEBUG
00241     fprintf(stderr,"[coT(%d).addAtom (int,int,string)] - %d,%d,%s\n",ownerSocket,objectID,atomType,str.c_str());
00242     #endif
00243 
00244     dataBaseIn->write ( pak );
00245     }

void DatabaseAccess::addAtom ( int ojbectID,
int atomType,
string str)

Adding an Binary- or String-Atom to an Object (and the Matrix).

Parameters:
objectID   the object the Atom shall be attached to
atomType   defines the type of the atom (Name, Socket, 3D-Position, Graphical Description...)
str   the content of the atom (might be binary or text)

Definition at line 227 of file databaseAccess.cpp.

00228 {
00229     packet* pak;
00230     pak = new packet;
00231 
00232     pak->h.from = ownerSocket;
00233 
00234     pak->h.header[0] = ODB_ADD_ATOM;
00235     pak->h.header[2] = objectID;
00236     pak->h.header[3] = atomType;
00237     pak->h.header[4] = -1;
00238     pak->data = str;
00239 
00240     #ifdef DEBUG
00241     fprintf(stderr,"[coT(%d).addAtom (int,int,string)] - %d,%d,%s\n",ownerSocket,objectID,atomType,str.c_str());
00242     #endif
00243 
00244     dataBaseIn->write ( pak );
00245     }

void DatabaseAccess::addEntity ( string objectName)

Adding an entity to the matrix using the name very similar to addObject, but it invokes the creation of an entity, not an object.

Parameters:
objectName   defines the name the object will be created with

Definition at line 189 of file databaseAccess.cpp.

00190 {
00191     packet* pak;
00192     pak = new packet;
00193 
00194     pak->h.from = ownerSocket;
00195 
00196     pak->h.header[0] = ODB_ADD_OBJECT;
00197     pak->h.header[1] = CLT_ENTITY;
00198     pak->h.header[2] = -1;
00199 
00200     pak->data = entityName;
00201 
00202     #ifdef DEBUG
00203     fprintf ( stderr,"[coT(%d).addEntity (string)] try to add an entity %s to Matrix\n",ownerSocket,entityName.c_str() );
00204     #endif
00205     dataBaseIn->write ( pak );
00206     }

void DatabaseAccess::addObject ( int objectID,
string objectName)

Adding an object to the matrix using a predefined ID and a name.

Parameters:
objectID   this ID shall be used to add this object to the Matrix
objectName   defines the name the object will be created with
Warning:
This is just possible on client-side!

Definition at line 169 of file databaseAccess.cpp.

00170 {
00171     packet* pak;
00172     pak = new packet;
00173 
00174     pak->h.from = ownerSocket;
00175 
00176     pak->h.header[0] = ODB_ADD_OBJECT;
00177     pak->h.header[1] = CLT_OBJECT;
00178     pak->h.header[2] = objectID;
00179 
00180     pak->data = objectName;
00181 
00182     #ifdef DEBUG
00183     fprintf ( stderr,"[coT(%d).addObject (id,string)] try to add an object %s to Matrix\n",ownerSocket,objectName.c_str() );
00184     #endif
00185     dataBaseIn->write ( pak );
00186     }

void DatabaseAccess::addObject ( string objectName)

The methods for adding Objects to the Matrix Adding an object to the matrix just using the name.

Parameters:
objectName   defines the name the object will be added with

Definition at line 150 of file databaseAccess.cpp.

00151 {
00152     packet* pak;
00153     pak = new packet;
00154 
00155     pak->h.from = ownerSocket;
00156 
00157     pak->h.header[0] = ODB_ADD_OBJECT;
00158     pak->h.header[1] = CLT_OBJECT;
00159     pak->h.header[2] = -1;
00160 
00161     pak->data = objectName;
00162 
00163     #ifdef DEBUG
00164     fprintf ( stderr,"[coT(%d).addObject (string)] try to add an object %s to Matrix\n",ownerSocket,objectName.c_str() );
00165     #endif
00166     dataBaseIn->write ( pak );
00167     }

void DatabaseAccess::addReason ( int objectIDa,
int objectIDb,
int reasonType)

Adding a link between two objects (with reason).

Parameters:
objectIDa   the parent object
objectIDb   the object that shall be linked to the parent object
reasonType   defines the reason of connection (Parent of, Part of, ..)

Definition at line 371 of file databaseAccess.cpp.

00372 {
00373     packet* pak;
00374     pak = new packet;
00375 
00376     pak->h.from = ownerSocket;
00377 
00378     pak->h.header[0] = ODB_ADD_REASON;
00379     pak->h.header[1] = objectIDa;
00380     pak->h.header[2] = objectIDb;
00381     pak->h.header[3] = reasonType;
00382 
00383     #ifdef DEBUG
00384     fprintf(stderr,"[coT(%d).addReason (int,int,int)] - %d,%d,%d\n",ownerSocket,objectIDa,objectIDb,reasonType);
00385     #endif
00386 
00387     dataBaseIn->write ( pak );
00388     }

void DatabaseAccess::getAllObjects ( void)

Request all new objects from the matrix.

See also:
myTimeStamp

Definition at line 79 of file databaseAccess.cpp.

00080 {
00081     packet* pak;
00082     pak = new packet;
00083 
00084 
00085     pak->h.from      = ownerSocket;
00086 
00087     pak->h.TimeStamp.tv_sec = myTimeStamp.tv_sec;
00088     pak->h.TimeStamp.tv_usec = myTimeStamp.tv_usec;
00089 
00090     pak->h.header[0] = ODB_GET_ALL_CHANGED;
00091 
00092     #ifdef DEBUG
00093     fprintf ( stderr,"[dbAccess(%d).getAllObjects]\n",ownerSocket);
00094     #endif
00095 
00096     dataBaseIn->write ( pak );
00097 
00098     gettimeofday ( &myTimeStamp, NULL );
00099     }

void DatabaseAccess::getAtom ( int atomID,
int objectID,
int atomType)

Requesting an Object from the Matrix.

Parameters:
atomID   the absolute ID of the Atom
objectID   the ID of the Atom's parent (used for performance reasons)
atomType   the type of the atom (also for performance reasons)

Definition at line 103 of file databaseAccess.cpp.

00104 {
00105     packet* pak;
00106     pak = new packet;
00107 
00108     pak->h.from = ownerSocket;
00109 
00110     pak->h.header[0] = ODB_GET_ATOM;
00111     pak->h.header[1] = AtomID;
00112     pak->h.header[2] = ObjectID;
00113     pak->h.header[3] = AtomType;
00114 
00115     #ifdef DEBUG2
00116     fprintf ( stderr,"[dbAccess(%d).getAtom] %d %d %d\n",ownerSocket,AtomID,ObjectID,AtomType);
00117     #endif
00118     dataBaseIn->write ( pak );
00119     }

void DatabaseAccess::getObject ( int objectID)

Requesting an Object from the Matrix.

Parameters:
objectID   this ID defines exactly the requested Object

Definition at line 122 of file databaseAccess.cpp.

00123 {
00124     packet* pak;
00125     pak = new packet;
00126 
00127     pak->h.from = ownerSocket;
00128 
00129     pak->h.header[0] = ODB_GET_OBJECT;
00130     pak->h.header[1] = ObjectNr;
00131 
00132     #ifdef DEBUG2
00133     fprintf(stderr,"[dbAccess(%d).getObject] ID --> %d <--\n",ownerSocket,ObjectNr );
00134     #endif
00135     dataBaseIn->write ( pak );
00136     }

void DatabaseAccess::removeReason ( int objectIDa,
int objectIDb,
int reasonType)

Removes a link between two objects (with reason).

Parameters:
objectIDa   the parent object
objectIDb   the object that shall be linked to the parent object
reasonType   defines the reason of connection (Parent of, Part of, ..) (note: objects can be linked with more than just one reason!)

Definition at line 402 of file databaseAccess.cpp.

00403 {
00404     packet* pak;
00405     pak = new packet;
00406 
00407     pak->h.from = ownerSocket;
00408 
00409     pak->h.header[0] = ODB_REMOVE_REASON;
00410     pak->h.header[1] = objectIDa;
00411     pak->h.header[2] = objectIDb;
00412     pak->h.header[3] = reasonType;
00413 
00414     #ifdef DEBUG
00415     fprintf(stderr,"[coT(%d).addReason (int,int,int)] - %d,%d,%d\n",ownerSocket,objectIDa,objectIDb,reasonType);
00416     #endif
00417 
00418     dataBaseIn->write ( pak );
00419     }

Member Data Documentation

Buffer * DatabaseAccess::dataBaseIn [private]

The Buffer the MatrixThread reads from.

Definition at line 33 of file databaseAccess.h.

timeval DatabaseAccess::myTimeStamp [private]

used to remember when the last update was.

Definition at line 34 of file databaseAccess.h.

int DatabaseAccess::ownerSocket [private]

defines the owner.

Definition at line 32 of file databaseAccess.h.


The documentation for this class was generated from the following files:
Generated at Sat May 13 13:50:24 2000 for 3Dsia by doxygen 1.1.2 written by Dimitri van Heesch, © 1997-2000