#include <databaseAccess.h>
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... | |
Buffer* | dataBaseIn |
The Buffer the MatrixThread reads from. More... | |
timeval | myTimeStamp |
used to remember when the last update was. More... |
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 }
|
The constructor for DatabaseAccess.
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 }
|
Adding an existing Long-Atom to an Object (and the Matrix).
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 |
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 }
|
Adding an existing Binary- or String-Atom to an Object (and the Matrix).
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) |
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 }
|
Adding a Long-Atom to an Object (and the Matrix).
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 }
|
Adding an Binary- or String-Atom to an Object (and the Matrix).
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 }
|
Adding an entity to the matrix using the name very similar to addObject, but it invokes the creation of an entity, not an object.
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 }
|
Adding an object to the matrix using a predefined ID and a name.
objectID | this ID shall be used to add this object to the Matrix |
objectName | defines the name the object will be created with |
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 }
|
The methods for adding Objects to the Matrix Adding an object to the matrix just using the name.
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 }
|
Adding a link between two objects (with reason).
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 }
|
Request all new objects from the matrix.
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 }
|
Requesting an Object from the Matrix.
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 }
|
Requesting an Object from the Matrix.
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 }
|
Removes a link between two objects (with reason).
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 }
|
|
|