In an object oriented database system, you need an object which represents the database itself. PtBase is a class which defines the methods for opening and closing the database and contains data which POET uses for internal management. Once you have opened a database you use the PtBase to assign other objects to the database.
You can have several PtBase objects open simultaneously, which allows you to manage several databases in your program. An object may only reference other objects in its database. The client/server version of POET allows several users to access the same database simultaneously with full concurrency control.
Before you open a PtBase you must call the global function InitPOET(), which creates a PtRoot object to manage the PtBases that you open. The best way to open a database is to call PtRoot:: GetBase() like this:
In the above code, the second parameter to GetBase() is the name of the database, and the first parameter is the name of the server to which we should connect. "LOCAL" means that we are in single-user mode. If we wanted to connect to a server then we would have specified the name of the server instead. For instance, if we wanted to connect to a server found on a computer named "DeepThought" we could use the following code:
In previous versions of POET, databases were created and opened using the PtBase, and there was no PtRoot. The advantage of using a PtRoot is that the PtRoot can ensure that the resources for each PtBase are allocated only once. Each PtBase you open requires file handles and RAM, and it takes time to open a database. GetBase() makes sure that you do not incur this overhead when you open a database a second time (footnote #1)
. You can still open a PtBase the old way, as long as you call InitPOET() first:
footnote #1:
Files to include | Class declaration | Base class |
poet.hxx | ptbase.hxx | none |
constructor | PtBase(); |
destructor | virtual ~PtBase(); |
AbortTransaction | int AbortTransaction(); |
AdjustServerThreads | int AdjustServerThreads(short amount); |
AuthorizationEnabled | int AuthorizationEnabled(); |
BeginExternalBackup | int BeginExternalBackup(const PtString& basename); |
BeginTransaction | int BeginTransaction(PtTransProps* pProps = NULL); |
BeTypeSafe | inline PtBool BeTypeSafe() const; |
cast2PtWorkspace | virtual PtWorkspace* cast2PtWorkspace(); |
CheckForEvent | virtual void CheckForEvent(); |
Clone | inline int Clone(const char* basename, PtCreateLocation location = PtSAME); |
Close | virtual int Close(); |
CloseAllChildren | int CloseAllChildren(); |
CommitTransaction | int CommitTransaction(); |
Connect | inline int Connect(const char* name); |
Create | inline int Create(const char* name, PtOpenMode mode = PtOPEN_RW, PtAssoc* assoc = __PtRootAssoc.first); |
CreateWorkspace | inline int CreateWorkspace(const char* basename, PtCreateLocation location = PtSAME); |
Delete | inline int Delete(const char* name, PtAssoc* assoc = __PtRootAssoc.first); |
DeleteUnusedChildren | inline int DeleteUnusedChildren(short& numDeletedChildren); |
DiscardWorkspace | inline int DiscardWorkspace(const char* name); |
DisConnect | virtual int DisConnect(); |
EnableAuthorization | int EnableAuthorization(const PtString& password, PtBoolool readable, PtBool writable, PtBool deletable); |
EndExternalBackup | int EndExternalBackup(const PtString& basename); |
GetClientId | inline const PtClientId& GetClientId() const; |
GetClientName | inline const PtString& GetClientName() const; |
GetCreationTime | int GetCreationTime(PtDateTime& ); |
GetCurrentUser | int GetCurrentUser(PtString& name, short& id); |
GetDbName | inline const PtString& GetDbName() const; |
GetDBVersion | void GetDBVersion(dword& dbversion, dword& poetversion, PtDate& compdate); |
GetDefaultLock | PtLockSpec* GetDefaultLock(); |
GetDefaultWatch | PtWatchSpec * GetDefaultWatch(); |
GetDictionary | PtClassDict* GetDictionary() const; |
GetDictName | inline const PtString& GetDictName() const; |
GetDictTimestamp | inline const PtDateTime& GetDictTimestamp() const; |
GetExcMgr | inline PtExcMgr* GetExcMgr() const; |
GetLast BaseError | inline int GetLastBaseError() const; |
GetLogicalDictName | inline const PtString& GetLogicalDictName() const; |
GetLogicalName | inline const PtString& GetLogicalName() const; |
GetNumClients | short GetNumClients(); |
GetObjectInfo | int GetObjectInfo(PtObjectState& Stat, long pos, const PtClientId* id = 0); |
GetOpenMode | inline PtOpenMode GetOpenMode() const; |
GetPhysicalDictName | inline const PtString& GetPhysicalDictName() const; |
GetPhysicalName | inline const PtString& GetPhysicalName() const; |
GetPhysicalServer | inline const PtString& GetPhysicalServer() const; |
GetServer | inline const PtString& GetServer() const; |
GetState | inline PtBaseState GetState() const; |
GetTypeMgr | inline PtTypeMgr* GetTypeMgr() const; |
IsDictionary | virtual int IsDictionary(); |
IsWorkspace | virtual int IsWorkspace(); |
MapName | int MapName(const PtString& sname, const PtString& name, PtString& mapped_name); |
MoveBase | inline int MoveBase(const PtString& baseFrom, const PtString& serverFrom, const PtString& baseTo, const PtString& serverTo); |
MoveServer | inline int MoveServer(const PtString& from, const PtString& to); |
Open | virtual int Open(const PtString& name,PtOpenMode mode = PtOPEN_RW, PtClassDict* = 0, PtAssoc* assoc = PtRootAssoc.first); |
POET | static PtRoot*& POET(); |
Recover | inline int Recover(const char* name, PtAssoc* assoc = __PtRootAssoc.first); |
Reorg | inline int Reorg(const char* name, PtAssoc* assoc = __PtRootAssoc.first); |
ReIndex | inline int ReIndex(const char* name, PtAssoc* assoc = __PtRootAssoc.first); |
SetBeTypeSafe | inline void SetBeTypeSafe(bool TypeChecking = PtTRUE); |
SetClientName | inline void SetClientName(PtString& name); |
SetDefaultLock | void SetDefaultLock(PtLockSpec* = 0); |
SetDefaultWatch | void SetDefaultWatch(PtWatchSpec* = 0); |
TransactionLevel | int TransactionLevel(); |
Update | inline int Update(const char* name, PtAssoc* assoc = __PtRootAssoc.first); |
VersAll | inline int VersAll(const char* name, PtAssoc* assoc = __PtRootA-ssoc.first); |
- PtBase::PtBase()
Creates a PtBase and registers it in the object management kernel. POET can manage and synchronize multiple instances of PtBase. The constructor does not connect the program to the server or open a database.
- PtBase::~PtBase()
Deletes the PtBase. You should first close the database and disconnect from the server. If the database is open then this method will close the database and disconnect from the server. All changes to objects in memory are lost if you do not store the objects before deleting the PtBase. Objects assigned to the database are removed from memory.
Important: You must delete or UnAssign() any objects, sets, or allsets that are assigned to the database before deleting the PtBase.
- int PtBase::AbortTransaction()
Aborts the current transaction. If you set an appropriate PtTransProps parameter for BeginTransaction(), the modified objects are automatically refreshed. See BeginTransaction() the description of the PtTransProps class.
>= 0 | The commit succeeded, and this is the new transaction level. |
ERR_PT_NO_TRANSACTION_RUNNING | You are not in a transaction. |
- int PtBase::AdjustServerThreads(short amount)
When using POET on a multi-threaded server, the server will create one thread for each database that a particular client opens. If your POET client opens two databases for example, the server will maintain two threads for that client. This may not be the most optimum from the client's point of view. If the client application executes multiple queries on one of the open databases, then the server will run these queries using a single thread on the server's machine. You can optimize this behavior from the client application with the method AdjustServerThreads().
The amount parameter tells the server to add the amount number of threads to the total number for the client's open database. For example, if you begin an operation that could benefit from an additional thread on the server, like a query, you could call AdjustServerThreads with an amount of one. This would add one extra thread to the number for the open client database. Here's an example of such a call:
As you can see from the example calls above, you can call AdjustServerThreads() with a negative amount to disable extra threads that are no longer needed. Values for the amount parameter greater than one are also possible. Remember, that the amount is the number of threads that you want to add (or remove) from the number of active threads on the server. Also, the server maintains these threads for a particular database and client. The AdjustServerThreads() call is only for the database (and client) that makes the call.
0 | The command succeeded. |
-25xx | Any of the possible communications error codes. |
- int PtBase::AuthorizationEnabled()
Returns a non-zero value if user authorization has been enabled for this database. User authorization is enabled by calling the function PtBase:: EnableAuthorization(). Once this function has been called, user accounts are created and no user may access the database without first logging in. See the chapter on user authorization in the programmer's guide for details.
- int PtBase::BeginExternalBackup(const PtString& basename)
Prepares the database for an external backup.
The parameter is currently ignored by this function. This function ensures that no changes are made to the database files while a database is being backed up. Clients may continue to use the database while the backup is being made. BeginExternalBackup() flushes all files to disk, starts a global internal transaction, closes the database, and opens the database files again in read-only mode. At this point you may safely copy the database files to make a backup. Any changes made by other clients will be saved in the internal transaction buffer for the database. When you are done with your backup, call EndExternalBackup() to restore the normal database state.
Note: internal transactions generally allocate disk space for each operation to ensure that this space is available if the transaction is later committed. During an external backup, internal transactions can not allocate memory since they do not have the files open. If memory is exhausted on the device, this will not be detected until EndExternalBackup() is called.
- int PtBase::BeginTransaction(PtTransProps* pProps = NULL)
POET supports nested transactions, which are described in a separate chapter. This method begins a transaction and returns the new transaction level.
The PtTransProps parameter determines the transaction behavior. Normally, you can simply call BeginTransaction() without a parameter, using the default value, NULL, for the PtTransProps pointer. However, you can control the transaction behavior by creating a PtTransProps object and passing its address to the BeginTransaction method.
For example, if you are not using indexed queries within the transaction you can use the transaction properties object to turn off the shadow indexes that are maintained during the transaction. You may also direct the transaction to do an automatic refresh of modified objects if you abort the transaction. See the description of the PtTransProps class and the Transactions chapter for a discussion of this extended transaction behavior.
- PtBool PtBase::BeTypeSafe() const
Run time type checking gives you strong type checking for all database operations which are not checked at compile time. This is very helpful during development, but type errors are unlikely to occur in mature software systems. Disabling run time type checking can speed database operations somewhat.
This method returns 0 if type checking is disabled or a non-zero value if type checking is enabled.
- virtual PtWorkspace* PtBase::cast2PtWorkspace()
If the database is actually a workspace, this method will return the database address as a PtWorkspace pointer. If the database is not a workspace, this method will return NULL.
- virtual void PtBase::CheckForEvent()
On systems which do not allow asynchronous events, such as the Macintosh, event handling is done by calling this function in the main program loop. CheckForEvent() asks the server to send any pending events, and forces your callback functions to be called. Currently, the Macintosh is the only system which needs to use this function. If you call this function on a system which does not need it, it just pings the server needlessly and then returns.
- int PtBase::Clone(const char* basename, PtCreateLocation location = PtSAME)
- int PtBase::Clone(const PtString& basename, PtCreateLocation location = PtSAME)
Clone() creates a new database which has the same dictionary and the same foreign database list. If you have read access to the user administration information, it also has the same user rights as the current database. If you do not have read rights to the user administration information, no user rights are assigned.
const char* basename const PtString& basename | The name for the new database |
PtCreateLocation location | PtLOCAL if the database is to be created with the local server, PtSAME if it is to be created using the same server as the database, or PtDICT if it is to be created using the same server as the dictionary. |
- int PtBase::Close()
0 | Success |
ERR_PT_NOT_OPENED | The PtBase is not open. |
- int PtBase::CloseAllChildren()
If you resolve a cross database reference for a database which is not yet open, POET opens the foreign database as a child of the PtBase which references it. This function closes all child databases for the PtBase.
- int PtBase::CommitTransaction()
Commits the current transaction. Non-negative return values report the new transaction level. Negative return values indicate that an error has occured during the commit. Since a commit is an all-or-nothing affair, the exact error is irrelevant.
If the commit fails no changes are written to the database.
>= 0 | The commit succeeded, and this is the new transaction level. |
ERR_PT_NO_TRANSACTION_RUNNING | You are not in a transaction. |
- inline int PtBase::Connect(const char* host)
- virtual int PtBase::Connect(const PtString& host)
Establishes a connection to the network server. To obtain source code compatibility it must be called in a single-user environment as well as in a multi-user environment.
host | Server name. Use "LOCAL" in single-user environment. |
In previous versions of POET, this was the only way to connect to a server, and connecting to a server and opening a database were done with separate function calls. It is now possible to connect to a server and open a database using PtRoot:: GetBase(), which is generally better because it ensures that your application only opens a given database once - if the database is already open, it simply returns a pointer to the existing database. We generally recommend that you use PtRoot:: GetBase() instead of PtBase:: Open().
By default, POET looks for a service called "poet" running on the specified host. This behavior can be changed using configuration files.
0 | Success |
ERR_PT_IS_CONNECTED | The PtBase is already connected |
ERR_PT_IS_OPENED | The PtBase is already opened |
ERR_PTC_NOCONNECTION | Unable to connect. The server is down, wrong server name, name resolution for the server is not working, something is wrong with your network installation... |
ERR_PT_TOO_MANY_USERS | You can not connect because there are too many users on the server for your current site license. |
- inline int PtBase::Create(const char* name, PtOpenMode mode = PtOPEN_RW, PtAssoc* assoc = __PtRootAssoc.first) virtual int PtBase::Create(const PtString& name, PtOpenMode mode = PtOPEN_RW, PtAssoc* assoc = __PtRootAssoc.first)
This method is used internally by POET. If you want to create a new database, do not use this method, use PtClassDict:: CreateDatabase() instead.
- inline int PtBase::CreateWorkspace(const char* basename, PtCreateLocation location = PtSAME) int PtBase::CreateWorksace(const PtString& basename, PtCreateLocation location = PtSAME)
Creates a workspace for the current database
const char* name const PtString& name | The name of the workspace |
PtCreateLocation location = PtSAME | PtSAME creates the workspace for the same server as the database. PtLOCAL creates the workspace locally. |
Workspaces are databases which can be used to check objects out of the original database. This function creates the files for a workspace. Within each database, each workspace name must be unique. If the workspace name has already been used for this database, an error will be returned. The workspace name may be an absolute or relative path, and it is interpreted just like any other database names in POET: if there you are working locally (without a server) then this name is relative to the current working directory; if you have a server, it is relative to the working directory of the server.
The second parameter determines whether the workspace will be created locally, or created on the same server as the original database (we would have specified PtSAME to create it on the same server). You can not create a workspace on a different server from the original database. Creating a workspace simply creates the files for the database, it does not create an open PtBase for the workspace. Before you can check objects out of or into the database, you must open the database as a PtWorkspace.
If you just want to use it as a normal database, you could open it using a PtBase.
- inline int PtBase::Delete(const char* name, PtAssoc* assoc = __PtRootAssoc.first) virtual int PtBase::Delete(const PtString& name, PtAssoc* assoc = __PtRootAssoc.first)
Deletes the database. Before calling this function, you must call PtBase:: Connect() to connect to the server (or to "LOCAL"), but the database should not be open. To protect the database, this function will fail if anybody has the database open - even if you have it open. The inline function simply creates a PtString and calls the virtual function. This preserves polymorphism, but reduces the number of virtual functions, which can be important on some compilers.
char* name const PtString& name | The name of the database to convert |
PtAssoc* assoc = __PtRootAssoc.first | Please do not specify this parameter; the default parameter is exactly what we need. |
- inline int PtBase::DeleteUnusedChildren()
If you resolve a cross database reference for a database which is not yet open, POET opens the foreign database as a child of the PtBase which references it. This function closes all child databases for the PtBase for which there are currently no objects in RAM.
- inline int PtBase::DiscardWorkspace(const char* name) int PtBase::DiscardWorkspace(const PtString& name)
Removes the workspace from the workspace list of the database. All persistent locks for objects belonging to the workspace are removed, and the objects are no longer checked out. The workspace will not be able to check objects in once this function has been called.
There is no way to undo DiscardWorkspace().
- int PtBase::DisConnect()
Breaks off the connection to the server.
0 | Success |
ERR_PT_NOT_CONNECTED | The PtBase is already disconnected, or was never connected in the first place |
- int PtBase::EnableAuthorization(const PtString& password, PtBool readable, PtBool writable, PtBool deletable)
Enables authorization for a database. When you first create a POET database anybody can read, write, or delete anything. To enable security for a database, you must first open the database, then call EnableAuthorization(). Once this function has been called, the database can only be opened after logging in as a user.
const PtString &password | The password for POETADM |
PtBool readable | Read access for the PtDefault group |
PtBool writable | Write access for the PtDefault group |
PtBool deletable | Delete access for the PtDefault group |
When you call EnableAuthorization(), POET creates the user POETADM, which is the database administrator, and logs your process in as POETADM. It also creates a default group, which will be assigned to any new user that you create, and an administrator's group, to which you can add any users who also need superuser access to the database. Here are the users and the groups that EnableAuthorization creates:
loginName | realName |
POETADM | The POET Administrator |
POETADMGROUP | The POET Administrator Group |
PtDefault | Default group for all POET users |
At first, there are no users except the administrator. Whenever a new user is created it belongs to the PtDefault group until it is moved to a different group. EnableAuthorization creates one more group called POETADMGROUP for users who should be able to act as database administrators.
- err = ObjBase.EnableAuthorization(PtString("flummery"),1,0,0);
In this example, the password for POETADM will be 'flummery,' and members of the PtDefault group will be able to read objects, but not write or delete them. When you call EnableAuthorization(), POET logs you in to the POETADM account.
Once you close the database, you will have to log in explicitly. Please keep track of the password for the POETADM account - if you lose it, there is no way to read it or to set it to a known password. If this happens to you, only POET Software will be able to make your database accessible again (even we can not figure out the password, but we do know how to enter a new password).
- int PtBase::EndExternalBackup(const PtString& basename)
Ends the external backup session started by calling BeginExternalBackup(). Closes all database files, re-opens them in read/write mode, and ends the internal transaction which was used to enable backups.
- const PtClientId& PtBase::GetClientId() const
Returns the client Id for your process.
- const PtString& PtBase::GetClientName() const
- int PtBase::GetClientName(PtString& name, PtClientId& id, short pos)
Provides the client name. Each of these functions is documented below.
- const PtString& PtBase::GetClientName() const
Returns the current client name for your process.
- int PtBase::GetClientName(PtString& name, PtClientId& id, short pos)
Returns the client name and Id for each client on the network who is currently using this database.
PtString& name | GetClientName() writes the client name into this string |
PtClientId& id | GetClientName() writes the client Id into this PtClientId |
short pos | The position in the client list |
If you want to see all clients, simply call this function in a for loop, incrementing the counter until GetClientName() returns an error:
- int PtBase::GetCreationTime(PtDateTime& )
Reports the date and time at which this database was originally created.
PtDateTime& | This function writes the date and time of creation into the PtDateTime. |
- int PtBase::GetCurrentUser(PtString& name, short& id)
Returns the client name and the client Id for your process.
PtString& name | The client name for your process. |
short& id | The client Id for your process. |
- const PtString& PtBase::GetDbName() const
Returns the name of the current database by reference. This name has been mapped by the local POET.CFG file, but does not have any mappings that are done on the server due to PTSERVER.CFG. For example, if your logical database name is BASE and this database is physically in the C:/APPS/APPBASE directory you will need to map this name in a POET.CFG or PTSERVER.CFG file. If the .CFG entry reads BASE=C:/APPS/APPBASE/OBJECTS.DAT then:
GetLogicalName() returns: | BASE |
GetDbName() returns: | C:/APPS/APPBASE/OBJECTS.DAT |
GetPhysicalName() returns: | C:/APPS/APPBASE |
- void PtBase::GetDBVersion(dword& dbversion, dword& poetversion, PtDate& compdate)
Reports the version number for the database, the version of POET which created it, and the compilation date of the POET version which was used to create it.
dword& dbversion | The version number of the database schema |
dword& poetversion | The version of POET that created this database |
PtDate& compdate | Compilation date of the POET version which was used to create the database |
- PtLockSpec* PtBase::GetDefaultLock()
Returns the default lock for the database. Locks and default locks are described in the chapter "Locking".
- PtWatchSpec* PtBase::GetDefaultWatch()
Returns the default watch for the database. Watches and default watches are described in the chapter "Event Handling".
- PtClassDict* PtBase::GetDictionary() const
Returns a pointer to the class dictionary manager for this database. This function is used only in programs that access the class dictionary.
- inline const PtString& PtBase::GetDictName() const
Returns the name of this database's dictionary. This is usually the physical name of the dictionary unless a POET.CFG has defined a different mapped name for the logical dictionary name.
For example, if your logical dictionary name is DICT and this dictionary is physically in the C:/APPS/APPDICT directory you will need to map this name in a POET.CFG or PTSERVER.CFG file. If the .CFG entry reads SCHEMA=C:/APPS/APPDICT/_OBJECTS.DAT then:
GetLogicalDictName() returns: | DICT |
GetDictName() returns: | C:/APPS/APPDICT/_OBJECTS.DAT |
GetPhysicalDictName() returns: | C:/APPS/APPDICT |
- inline const PtDateTime& PtBase::GetDictTimestamp() const
Returns the creation date and time of the database's dictionary as a PtDateTime reference.
- inline PtExcMgr* PtBase::GetExcMgr() const
Returns a pointer to the database's exception manager. Exception managers are used for event handling, and are described in the chapter "Event Handling."
- int PtBase::GetLastBaseError() const
This method returns an undocumented error code which describes the last database error. These error codes are used for POET development, and can be helpful when reporting errors to technical support.
- inline const PtString& PtBase::GetLogicalDictName() const
Returns the logical name of the dictionary, which is the string that you used when you created the dictionary using PTXX. This string is stored in the root block of the database.
- inline const PtString& PtBase::GetLogicalName() const
Returns the logical name of the database, which is the string that you used in your PtBase:: Open() statement when you opened the database.
- short PtBase::GetNumClients()
Returns the number of clients currently using this database.
- int PtBase::GetObjectInfo(PtObjectState& State, long pos, const PtClientId* id=0)
Returns information on the objects being used by a client.
PtObjectState& State | GetObjectInfo() writes the object state information into this PtObjectState |
long pos | The number of the object you are interested in. You can find all objects by setting this sequentially. |
const PtClientId* id=0 | The PtClientId for the client you are interested in. If 0, searches for all clients. |
This function fills the PtObjectState with information on the requested object. The type of information depends on the full type of the PtObjectState. For instance, if you specify a PtObjStateMaxLock, you will receive information on the maximum lock for each locked object, and pos will iterate through only the locked objects. PtObjStateLockList reports all locks for each locked object, and pos iterates through only the watched objects. PtObjStateWatchList reports the watches for each watched object, and pos iterates through only the watched objects. If you specify a PtObjStateObjectInfo, you will receive all available status information on the objects which are in the RAM of each client.
- inline PtOpenMode PtBase::GetOpenMode() const
Returns the open mode for this database. See PtBase::Open().
- inline const PtString& PtBase::GetPhysicalDictName() const
Returns the full absolute path name of the dictionary. If you are using a server, this is the name as understood by the server, after any mappings done due to the server's PTSERVER.CFG file.
- inline const PtString& PtBase::GetPhysicalName() const
Returns the full absolute path name of the database. If you are using a server, this is the name as understood by the server, after any mappings done due to the server's PTSERVER.CFG file.
- inline const PtString& PtBase::GetPhysicalServer() const
Returns the physical name of the server, after any mappings due to the client's POET.CFG file.
- const PtString& PtBase::GetServer() const
Returns the current server name by reference.
- PtBaseState PtBase::GetState()
Returns the current database status. Here is the state table for a PtBase:
Previous state | Action | New state |
Non-existent | call constructor | PtINITIALIZED |
PtINITIALIZED | connect to server | PtCONNECTED |
PtCONNECTED | open database | PtOPENED |
PtCONNECTED | disconnect | PtINITIALIZED |
PtINITIALIZED | The PtBase has been created. |
PtCONNECTED | A connection to the server has been established. |
PtOPENED | A database is open. |
- inline PtTypeMgr* PtBase::GetTypeMgr() const
Returns a pointer to the type manager, which manages C++ base types and type manager types for POET. This function is useful primarily for some class dictionary and generic object programming.
- virtual int PtBase::IsDictionary()
Returns a non-zero value if this database is a class dictionary. Every database has a class dictionary associated with it, and the class dictionary is also a database.
- virtual int PtBase::IsWorkspace()
Returns a non-zero value if this database is a Workspace.
- int PtBase::MapName(const PtString& sname, const PtString& name, PtString& mapped_name)
Maps a name using the configuration file entries.
const PtString& sname | The name of the server. If you use an empty string, only the mappings from the local POET.CFG file will be applied. If you specify the name of a server, both the POET.CFG mappings and the PTSERVER.CFG mappings will be applied. |
const PtString& name | The name which you want to map. |
PtString& mapped_name | MapName() writes the mapped name into this string. |
This function can be used to map any names specified in the POET.CFG or PTSERVER.CFG configuration files. For instance, you can find the current value of "VerboseMode" by passing it as the second parameter to this function, or you can use this to see how logical names are mapped.
- inline int PtBase::MoveBase(const PtString& baseFrom, const PtString& serverFrom, const PtString& baseTo, const PtString& serverTo)
This function does not actually move a database, it just changes the name of the database in the foreign database table. If your database has ondemand references to objects in other databases, the names of these databases are kept in a table called the foreign database table. If the foreign database is moved to a different location or a different server, the foreign database table must be updated so that POET can find the foreign database.
const PtString& baseFrom | The previous name of the database |
const PtString& serverFrom | The previous database server |
const PtString& baseTo | The new name of the database |
const PtString& serverTo | The new database server |
- inline int PtBase::MoveServer(const PtString& from, const PtString& to)
This function changes the name of the server in the foreign database table. If your database has ondemand references to objects in other databases, the names of the servers are kept in a table called the foreign database table. If the foreign database is moved to a different location or a different server, the foreign database table must be updated so that POET can find the foreign database.
const PtString& from | The previous database server |
const PtString& to | The new database server |
- virtual int Open(const PtString& name,PtOpenMode mode = PtOPEN_RW, PtClassDict* dict = 0, PtAssoc* assoc = PtRootAssoc.first);
- inline int Open(const char* name, PtOpenMode mode = PtOPEN_RW, PtClassDict* dict = 0, PtAssoc* assoc = __PtRootAssoc.first);
Opens the database name on the current server. You will normally specify only the first parameter.
The inline function simply creates a PtString and calls the virtual function. This preserves polymorphism, but reduces the number of virtual functions, which can be important on some compilers.
name | The name of the database |
PtOpenMode mode | This is an enumerated value and may be one of the following: PtOPEN_RW for read/write access (the default) PtOPEN_READ for read-only access |
PtClassDict* dict | If not NULL, this is the dictionary you want to use with this database. This will override the named dictionary and is rarely used. |
PtAssoc* assoc | This is the pointer to the class factory. This may be set to NULL when using the database in a pure generic environment. The generic interface is described in a separate document. |
In previous versions of POET, this was the only way to open a database. It is now possible to connect to a server and open a database using PtRoot:: GetBase(), which is generally better because it ensures that your application only opens a given database once - if the database is already open, it simply returns a pointer to the existing database. We generally recommend that you use PtRoot:: GetBase() instead of PtBase:: Open(). The database name is the name of the directory which contains the database files. It may be specified as a relative path or an absolute path. If you use a relative path under Windows, please note that the default home directory is the directory in which the executable resides. In previous versions of POET, this name was also interpreted as the schema name. This is no longer true. The database has the name of its class dictionary in its database header, and this class dictionary name will be used to open the dictionary. The dictionary, in turn, has the name of the class factory table in its header. This name must match the name used to generate the class factory files in the POET IDE.
You can use configuration files to map the database name or dictionary name to any physical directory anywhere on the network; for details, see the section on logical database names in the chapter "Configuration Files."
0 | Success |
ERR_PT_NOT_CONNECTED | The PtBase is not connected |
ERR_PT_IS_OPENED | The PtBase is already opened |
ERR_PT_NO_DATABASE | The database files could not be found |
ERR_PT_FACTORY_NOT_FOUND | Could not find the class factory table for your schema. |
ERR_PT_NO_DICTIONARY | The dictionary could not be found. This can happen if somebody moved the database or the dictionary. |
- static PtRoot*& PtBase::POET()
Returns a pointer to the PtRoot object for this database.
- inline int PtBase::Recover(const char* name, PtAssoc* assoc = __PtRootAssoc.first); virtual int PtBase::Recover(const PtString& name, PtAssoc* assoc = __PtRootAssoc.first);
Commits any valid forward recovery logs to the database. There will only be a valid recovery log if the server crashed while writing to the database. Even then, you usually do not need to use this function, because POET always commits any valid forward recovery logs when it opens a database. Before calling this function, you must call PtBase:: Connect() to connect to the server (or to "LOCAL"), but the database should not be open. To protect the database, this function will fail if anybody has the database open - even if you have it open.
The inline function simply creates a PtString and calls the virtual function. This preserves polymorphism, but reduces the number of virtual functions, which can be important on some compilers.
const char* name const PtString& name | The name of the database to recover |
PtAssoc* assoc = __PtRootAssoc.first | Please do not specify this parameter; the default parameter is exactly what we need. |
- inline int PtBase::ReIndex(const char* name, PtAssoc* assoc = __PtRootAssoc.first) virtual int PtBase::ReIndex(const PtString& name, PtAssoc* assoc = __PtRootAssoc.first)
Regenerates the indexes using the data from the objects in the database. Progress callbacks are generated while this is happening. Before calling this function, you must call PtBase:: Connect() to connect to the server (or to "LOCAL"), but the database should not be open. To protect the database, this function will fail if anybody has the database open - even if you have it open.
The inline function simply creates a PtString and calls the virtual function. This preserves polymorphism, but reduces the number of virtual functions, which can be important on some compilers.
const char* name const PtString& name | The name of the database to reindex |
PtAssoc* assoc = __PtRootAssoc.first | Please do not specify this parameter; the default parameter is exactly what we need. |
PtBase::Update() calls ReIndex() only if it is necessary. If you call Update() instead of ReIndex() then you will not rebuild the indexes unless you really have to.
- inline int PtBase::Reorg(const char* name, PtAssoc* assoc = __PtRootAssoc.first) virtual int PtBase::Reorg(const PtString& name, PtAssoc* assoc = __PtRootAssoc.first)
Discards the indexes for the database and regenerates them using the data from the objects in the database. Also optimizes the disk allocation for any objects which have become fragmented. Progress callbacks are generated while this is happening.
Before calling this function, you must call PtBase:: Connect() to connect to the server (or to "LOCAL"), but the database should not be open. To protect the database, this function will fail if anybody has the database open - even if you have it open.
The inline function simply creates a PtString and calls the virtual function. This preserves polymorphism, but reduces the number of virtual functions, which can be important on some compilers.
const char* name const PtString& name | The name of the database to reorganize |
PtAssoc* assoc = __PtRootAssoc.first | Please do not specify this parameter; the default parameter is exactly what we need. |
- void PtBase::SetBeTypeSafe(bool TypeChecking = PtTRUE)
Sets run time type checking on or off. PtTRUE turns type checking on, PtFALSE turns it off.
- void PtBase::SetClientName(PtString& name)
Sets the client's name for this database and server. Should be called before connect().
- void PtBase::SetDefaultLock(PtLockSpec* = 0)
Sets the default lock for the database. Locks and default locks are described in the chapter "Locking".
- void PtBase::SetDefaultWatch(PtLockSpec* = 0)
Sets the default watch for the database. Watches and default watches are described in the chapter "Event Handling".
- int PtBase::TransactionLevel()
Returns the current transaction level for the database.
- inline int PtBase::Update(const char* name, PtAssoc* assoc = __PtRootAssoc.first) virtual int PtBase::Update(const PtString& name, PtAssoc* assoc = __PtRootAssoc.first)
When a dictionary has changes in its indexes, the database may need to be updated. This function updates the database indexes to allow you to open and use the database; it always makes as few changes as possible. If there are new indexes in the dictionary, it creates the new indexes. If indexes have changed, it does a PtBase::ReIndex(). If changes are so drastic that you need to do a PtBase::VersAll(), it does so. Progress callbacks are generated while this is happening.
Before calling this function, you must call PtBase:: Connect() to connect to the server (or to "LOCAL"), but the database should not be open. To protect the database, this function will fail if anybody has the database open - even if you have it open.
The inline function simply creates a PtString and calls the virtual function. This preserves polymorphism, but reduces the number of virtual functions, which can be important on some compilers.
const char* name const PtString& name | The name of the database to update |
PtAssoc* assoc = __PtRootAssoc.first | Please do not specify this parameter; the default parameter is exactly what we need. |
- inline int PtBase::VersAll(const char* name, PtAssoc* assoc = __PtRootAssoc.first) virtual int PtBase::VersAll(const PtString& name, PtAssoc* assoc = __PtRootAssoc.first)
Uses schema versioning to convert all objects in the database to the most recent version that is registered in the class dictionary. Progress callbacks are generated while this is happening.
Before calling this function, you must call PtBase:: Connect() to connect to the server (or to "LOCAL"), but the database should not be open. To protect the database, this function will fail if anybody has the database open - even if you have it open.
The inline function simply creates a PtString and calls the virtual function. This preserves polymorphism, but reduces the number of virtual functions, which can be important on some compilers.
const char* name const PtString& name | The name of the database to convert |
PtAssoc* assoc = __PtRootAssoc.first | Please do not specify this parameter; the default parameter is exactly what we need. |
Copyright (c) 1996 POET Software, Inc. All rights reserved. Reproduction in whole or in part in any form or medium without the express permission of POET Software, Inc. is prohibited.