1.1 --- a/epoc32/include/metadatabase.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/metadatabase.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,1670 @@
1.4 -metadatabase.h
1.5 +// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +// All rights reserved.
1.7 +// This component and the accompanying materials are made available
1.8 +// under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
1.9 +// which accompanies this distribution, and is available
1.10 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.11 +//
1.12 +// Initial Contributors:
1.13 +// Nokia Corporation - initial contribution.
1.14 +//
1.15 +// Contributors:
1.16 +//
1.17 +// Description:
1.18 +// Meta-database declarations for use in storing comms data
1.19 +//
1.20 +//
1.21 +
1.22 +
1.23 +
1.24 +/**
1.25 + @file
1.26 + @publishedPartner
1.27 + @released
1.28 +*/
1.29 +
1.30 +
1.31 +#if (!defined METADATABASE_H)
1.32 +#define METADATABASE_H
1.33 +
1.34 +
1.35 +
1.36 +// NetMeta headers
1.37 +#include <comms-infras/metadata.h>
1.38 +#include <comms-infras/metatype.h>
1.39 +
1.40 +// CommsDat headers
1.41 +#include <commsdat.h>
1.42 +
1.43 +
1.44 +
1.45 +/**@plaintext
1.46 +
1.47 +This file contains :
1.48 +
1.49 +1/ Class for expressing a session with the storage server
1.50 +
1.51 + CMDBSession
1.52 +
1.53 + This class contains functions to create and close a session, to set the dataset version
1.54 + and to request database actions such as locking for a transaction.
1.55 +
1.56 +2/ Generic database functionality interface
1.57 +
1.58 + MMetaDatabase
1.59 +
1.60 + This class uses a CMDBSession object
1.61 +
1.62 +
1.63 +3/ General base class that inherits from MMetaDatabase to express any database element
1.64 +
1.65 + CMDBElement
1.66 +
1.67 + This class contains the ElementId for each MetaDatabase object
1.68 + An element id locates stored data in the comms database.
1.69 +
1.70 +
1.71 +4/ Data classes that each inherit from CMDBElement
1.72 +
1.73 + a) Fields
1.74 +
1.75 + CMDBField<T>
1.76 +
1.77 + where T is a basic type value of the field (TInt, TDes, TBool etc)
1.78 +
1.79 + This class derives from
1.80 +
1.81 + CMDBElement
1.82 +
1.83 + to implement the thin template idiom
1.84 +
1.85 +
1.86 + CMDBRecordLink<T>
1.87 +
1.88 + where T is a record of a particular type. This class expresses a soft-link
1.89 + from a field in one record to a record of a different type (i.e. in another table).
1.90 + The TMDBElementId value stored in this field in the repository is the id of an instance
1.91 + of the record of type T
1.92 +
1.93 + This class derives from
1.94 +
1.95 + CMDBRecordLinkBase
1.96 +
1.97 + to implement the thin template idiom
1.98 +
1.99 +
1.100 + b) Field Containers
1.101 +
1.102 +
1.103 + CCDRecord
1.104 +
1.105 + base class for record containing specific list of fields - see CommsDatTypesv1_1.h
1.106 +
1.107 +
1.108 + CMDBRecordSet<T>
1.109 +
1.110 + an array of records where T is the record type. This can represent a Table in a database.
1.111 +
1.112 +
1.113 +
1.114 +
1.115 +5/ Other support classes and type definitions
1.116 +
1.117 + TMDBElementId
1.118 +
1.119 + The TMDBElementId locates a data object or set of data objects in the database.
1.120 +
1.121 + A TMDBElementId expresses
1.122 +
1.123 + <TableId><ColumnId><RecordId><Attributes>
1.124 +
1.125 + A TMDBElementId has a different format depending on the data type it expresses
1.126 +
1.127 + Table <TableId><0><0>
1.128 + Column <TableId><ColumnId><0>
1.129 +
1.130 + Record <TableId><0><RecordId>
1.131 + Field <TAbleId><ColumnId><RecordId>
1.132 +
1.133 +
1.134 + TMDBAttributeFlags
1.135 +
1.136 + Attribute settings for any storable element.
1.137 + Attributes express access control for data in the database
1.138 +
1.139 +*/
1.140 +
1.141 +
1.142 +
1.143 +namespace CommsDat
1.144 +{
1.145 +
1.146 +using namespace Meta;
1.147 +
1.148 +
1.149 +// Private to implementation
1.150 +//@internalTechnology
1.151 +//@released
1.152 +class CMDBSessionImpl;
1.153 +
1.154 +// Forward declarations
1.155 +class MMetaDatabase;
1.156 +class CMDBElement;
1.157 +
1.158 +/**
1.159 +Attribute flags for an element in the Meta Database
1.160 +Attributes describe access rights to the data in the database
1.161 +@publishedAll
1.162 +@released
1.163 +*/
1.164 +typedef TUint32 TMDBAttributeFlags;
1.165 +
1.166 +
1.167 +/**
1.168 +The identifier for any entry in the MetaDatabase.
1.169 +It can specify
1.170 + <TableId><ColumnId><RecordId>
1.171 +This identifies
1.172 + The data location in the database
1.173 + The meaning of the data within in the data schema
1.174 + The type of the data
1.175 +
1.176 +@publishedAll
1.177 +@released
1.178 +*/
1.179 +typedef TUint32 TMDBElementId;
1.180 +
1.181 +class CMDBSession : public CBase
1.182 +/*
1.183 +A session with the underlying storage server
1.184 +@publishedAll
1.185 +@released
1.186 +*/
1.187 +{
1.188 +public:
1.189 +
1.190 + /**
1.191 + Open a session with the storage server and establish data format version in use
1.192 + CommsDat always attempts to support the required version of the client-facing data set.
1.193 + The client must carefully choose the dataset version as it affects binary compatibility
1.194 +
1.195 + @params aRequiredVersion
1.196 + If the requested version is deprecated but still supported, mapping will be performed
1.197 + within CommsDat to maintain Data and Binary compatibility for the client
1.198 + If the requested version is the latest version, no mapping will be performed
1.199 + and deprecated fields will be ignored
1.200 + A client that needs to maintain BC must use a specific version
1.201 + A client that always wants to use the latest dataset can start the session with KCDLatestVersion
1.202 +
1.203 + @leave KErrUnsupported If an old unsupported version is requested
1.204 + @leave System-wide error codes if there is an unexpected error
1.205 +
1.206 + @pre None
1.207 + @post on success a session has been created and initialised
1.208 +
1.209 + @publishedAll
1.210 + */
1.211 + IMPORT_C static CMDBSession* NewL(TVersion aRequiredVersion);
1.212 +
1.213 + /**
1.214 + As NewL and adds Session to the CleanupStack
1.215 +
1.216 + @publishedAll
1.217 + */
1.218 + IMPORT_C static CMDBSession* NewLC(TVersion aRequiredVersion);
1.219 +
1.220 + /**
1.221 + Virtual Destructor
1.222 +
1.223 + @publishedAll
1.224 + */
1.225 + IMPORT_C ~CMDBSession();
1.226 +
1.227 +
1.228 + /**
1.229 + Close session with storage server.
1.230 +
1.231 + @publishedAll
1.232 + @deprecated v9.1 Destructor is all that is required
1.233 + */
1.234 + IMPORT_C void Close();
1.235 +
1.236 +
1.237 + /**
1.238 + Lookup latest data format version
1.239 +
1.240 + @pre None
1.241 + @post None
1.242 + @publishedAll
1.243 + */
1.244 + IMPORT_C static TVersion LatestVersion();
1.245 +
1.246 +
1.247 + /**
1.248 + Lookup data format version currently in use by client
1.249 +
1.250 + @publishedAll
1.251 + */
1.252 + IMPORT_C TVersion VersionInUse();
1.253 +
1.254 +
1.255 + /**
1.256 + Open Transaction with storage server and obtain write lock - if not already set
1.257 +
1.258 + @capability WriteDeviceData
1.259 +
1.260 + @leave Will leave with KErrNotAvailable if Database write locked by another process
1.261 + @leave Will report KErrAlreadyInTransaction if transaction this session is already in a transaction
1.262 + @leave Will leave with a system-wide error code if an error occurs during commit
1.263 +
1.264 + @pre None
1.265 + @post on success the session has exclusive write access to the database
1.266 +
1.267 + @publishedAll
1.268 + */
1.269 + IMPORT_C void OpenTransactionL();
1.270 +
1.271 +
1.272 + /**
1.273 + Commit Transaction in database.
1.274 +
1.275 + @leave Will leave with KErrNotFound if not in transaction
1.276 + @leave Will leave with a system-wide error code if an error occurs during commit
1.277 +
1.278 + @pre None
1.279 +
1.280 + @post On success the database is updated with data added, modified or deleted during the transaction
1.281 + @post On failure, any open data containers may not be in sync with the database and should be discarded or reloaded
1.282 + @publishedAll
1.283 + */
1.284 + IMPORT_C void CommitTransactionL();
1.285 +
1.286 +
1.287 + /**
1.288 + Cancel Transaction with database and rollback all associated changes
1.289 + Will not make any changes to the client's containers
1.290 +
1.291 + @leave Will fail with KErrNotFound if not in transaction
1.292 +
1.293 + @pre None - though for correct usage, ensure a transaction is already open
1.294 + @post Any open data containers may not be in sync with the database and should be discarded or reloaded
1.295 + @publishedAll
1.296 + */
1.297 + IMPORT_C void RollbackTransactionL();
1.298 +
1.299 + /**
1.300 + Query if this session is in a transaction with the database
1.301 + Return code will indicate
1.302 + Not in transaction,
1.303 + Already in transaction for this session,
1.304 + Write-lock not available. Another session has it.
1.305 +
1.306 + @pre None
1.307 + @publishedAll
1.308 + */
1.309 + IMPORT_C TInt IsInTransaction();
1.310 +
1.311 +
1.312 + /**
1.313 + Set attributes to ignore for all database operations during this session
1.314 +
1.315 + @params aAttributeFlags indicates the requested access level to stored data.
1.316 + Attributes set by this call will be ignored as restrictions in all database interactions,
1.317 + providing the client has enough platform security capabilities to back up the request
1.318 +
1.319 + @pre None
1.320 + @publishedAll
1.321 + */
1.322 + IMPORT_C void SetAttributeMask(TMDBAttributeFlags aAttributeFlags);
1.323 +
1.324 +
1.325 + /**
1.326 + Check flags in attribute mask
1.327 + @params aAttributeFlags indicates the requested access level to stored data
1.328 + Attribute flags that have been set will be ignored as restrictions in all database interactions,
1.329 + providing the client has enough platform security capabilities to back up the request
1.330 +
1.331 + @return ETrue if the flag is set in the session mask
1.332 + This means that the attribute is ignored in database interactions for this session
1.333 +
1.334 + @return EFalse if the flag is not set in the session mask
1.335 + This means that the attribute is obeyed in all database interactions for this session
1.336 +
1.337 + @pre None
1.338 + @publishedAll
1.339 + */
1.340 + IMPORT_C TBool IsSetAttributeMask(TMDBAttributeFlags aAttributeFlags);
1.341 +
1.342 +
1.343 + /**
1.344 + Clear attribute mask settings, indicating required access level to stored data
1.345 + Clear flags in the attribute mask for this session
1.346 +
1.347 + Flags indicate the requested access level to stored data
1.348 +
1.349 + Attribute flags that have been set in this function will be cleared from the session's
1.350 + attribute mask and will be obeyed as restrictions in all database interactions,
1.351 + providing the client has enough platform security capabilities to back up the request
1.352 +
1.353 + @pre None
1.354 +
1.355 + @publishedAll
1.356 + */
1.357 + IMPORT_C void ClearAttributeMask(TMDBAttributeFlags aAttributeFlags);
1.358 +
1.359 +
1.360 +
1.361 + /**
1.362 + Cancel all notification requests that are outstanding from calls to
1.363 + MMetaDatabase::RequestNotification
1.364 + Individual requests can be cancelled via MMetaDatabase::CancelNotify.
1.365 +
1.366 + @return KErrNone on success or a system-wide error code
1.367 +
1.368 + @pre None
1.369 +
1.370 + @publishedAll
1.371 + */
1.372 + IMPORT_C TInt CancelAllNotifications();
1.373 +
1.374 +
1.375 + /**
1.376 + Attempt to create publish/subscribe properties if not already defined.
1.377 +
1.378 + This function is normally called as a setup activity by System components
1.379 +
1.380 + @capability WriteDeviceData - since these properties are created in KUidSystemCategory category.
1.381 +
1.382 + @return KErrNone on success. Otherwise a system-wide error code
1.383 +
1.384 + @pre None
1.385 +
1.386 + @internalComponent
1.387 + */
1.388 + IMPORT_C TInt PublishProperties();
1.389 +
1.390 +private:
1.391 +
1.392 + TInt ConstructL( TVersion aRequiredVersion );
1.393 +
1.394 + CMDBSession();
1.395 +
1.396 +private:
1.397 +
1.398 + CMDBSessionImpl* iMDBSessionImpl;
1.399 +
1.400 + friend class MMetaDatabase;
1.401 +};
1.402 +
1.403 +
1.404 +
1.405 +
1.406 +
1.407 +class MMetaDatabase : public Meta::MMetaData
1.408 +/*
1.409 +Interface for interaction with a database server
1.410 +Inherited by each data set type that can be stored
1.411 +@publishedAll
1.412 +*/
1.413 +{
1.414 +public:
1.415 +
1.416 + IMPORT_C virtual ~MMetaDatabase();
1.417 +
1.418 +
1.419 + /**
1.420 + LoadL - Load this container with data from the database
1.421 +
1.422 + Any data in the container will be discarded
1.423 +
1.424 + Individual fields may legitimately be NULL in the database, but if no data at all
1.425 + is found for an entire table or record, LoadL will leave with
1.426 + KErrNotFound
1.427 +
1.428 + The client can request to ignore access control flags by setting the attribute mask
1.429 + CMDBSession::SetAttributeMask()
1.430 + However, only fields that the client has capabilities to write will be stored in the database
1.431 + A request to read data from an unauthorised area of the database will cause the function to leave.with
1.432 + KErrPermissionDenied
1.433 +
1.434 + In a record, fields in an unauthorised column may be silently ignored and returned as NULL
1.435 +
1.436 + May also leave with KErrNoMemory or other general error codes
1.437 +
1.438 + On failure, the container should be discarded or reloaded before it is used again
1.439 +
1.440 + @pre
1.441 +
1.442 + Ensure the ElementId for this container fully identifies the target data in the database
1.443 + <Table><Column><Record>
1.444 + Ensure that the session object has been initialised with the correct dataset version
1.445 + Ensure that the session object has appropriate access control attributes to manage the target data in the database
1.446 +
1.447 + @publishedAll
1.448 + */
1.449 + IMPORT_C void LoadL(CMDBSession& aSession);
1.450 +
1.451 +
1.452 + /**
1.453 + FindL - Find and Load the data set(s) that match all the data values entered by the
1.454 + client in this container
1.455 +
1.456 + Client can request to ignore access control flags by setting the attribute mask,
1.457 + CMDBSession::SetAttributeMask()
1.458 + However will not load data that the client is not authorised to see (by platsec)
1.459 + even if the client has sets the appropriate attribute mask
1.460 +
1.461 + Will return
1.462 + ETrue on success
1.463 + EFalse if no data found that the client is authorised to view
1.464 +
1.465 + May also leave with KErrGeneral or other general error codes.
1.466 +
1.467 + On failure, the container should be discarded or repopulated before it is used again
1.468 +
1.469 + @pre
1.470 +
1.471 + Populate this container where necessary with valid data to match during the find operation
1.472 + Ensure the ElementId for this container correcty identifies the target table in the database
1.473 + <Table><Column>
1.474 + Ensure that the session object has been initialised with the correct dataset version
1.475 + Ensure that the session object has appropriate access control attributes to manage the target data in the database
1.476 + @publishedAll
1.477 + */
1.478 + IMPORT_C TBool FindL(CMDBSession& aSession);
1.479 +
1.480 +
1.481 + /**
1.482 + Refresh all fields in the container that have not been changed by the client
1.483 +
1.484 + The client can request to ignore access control flags by setting the attribute mask,
1.485 + CMDBSession::SetAttributeMask()
1.486 + However, only data that the client has capabilities to view will be loaded
1.487 + Unauthorised data elements will be silently ignored and will remain NULL
1.488 +
1.489 + If no data at all is found the functon will leave with
1.490 + KErrNotFound
1.491 +
1.492 + If fields are not accessible for reading the function may leave with
1.493 + KErrPermissionDenied
1.494 +
1.495 + May also leave with other general error codes if there are unexpected
1.496 + problems (e.g. KErrNoMemory when out of memory)
1.497 +
1.498 + On failure, the container should be discarded or reloaded before it is used again
1.499 +
1.500 + @pre
1.501 +
1.502 + Ensure the ElementId for this container fully identifies the target data in the database
1.503 + <Table><Column><Record>
1.504 + Ensure that the session object has been initialised with the correct dataset version
1.505 + Ensure that the session object has appropriate access control attributes to manage the target data in the database
1.506 + @publishedAll
1.507 + */
1.508 + IMPORT_C void RefreshL(CMDBSession& aSession);
1.509 +
1.510 +
1.511 + /**
1.512 + StoreL - Store all fields in the database that have been changed in this container and
1.513 + create new records where necessary.
1.514 +
1.515 + StoreL is atomic for this container. An internal transaction is used even if
1.516 + no overall transaction is set by client.
1.517 + All changed fields in the element are stored in the database on success.
1.518 + No fields or records are stored in the database if the function leaves
1.519 +
1.520 + If a client has an open transaction in the session, the stored data will be available to this session as
1.521 + soon as StoreL completes but will not be visible to other sessions until the transaction completes successfully
1.522 +
1.523 + The client can request to ignore access control flags by setting the attribute mask
1.524 + CMDBSession::SetAttributeMask()
1.525 + However, only fields that the client has capabilities to write will be stored in the database
1.526 + A request to modify data in an unauthorised area of the database will cause the function to leave.with
1.527 + KErrPermissionDenied
1.528 +
1.529 + If a field already exists, StoreL will leave with
1.530 + KErrAlreadyExists
1.531 +
1.532 + May also leave with other general error codes if there are unexpected
1.533 + problems (e.g. KErrNoMemory when out of memory)
1.534 +
1.535 +
1.536 + If StoreL fails or the later commit is not successful, The data in the container will not
1.537 + match the data in the database.
1.538 +
1.539 + On failure, the container should be discarded or repopulated before it is used again
1.540 +
1.541 + @pre
1.542 +
1.543 + Populate this container with valid data for storage
1.544 + Ensure the ElementId for this container fully identifies the target location in the database
1.545 + <Table><Column><Record>
1.546 + Ensure that the session object has been initialised with the correct dataset version
1.547 + Ensure that the session object has appropriate access control attributes to manage the target data in the database
1.548 +
1.549 + @publishedAll
1.550 + */
1.551 + IMPORT_C void StoreL(CMDBSession& aSession);
1.552 +
1.553 +
1.554 + /**
1.555 + Modify all fields in the database that have been changed in this container by the caller
1.556 +
1.557 + Only modifies existing data in the database, won't create new fields VCT - is this true?? don't think so
1.558 +
1.559 + Modification is atomic for this container. It uses an internal transaction even if
1.560 + no overall transaction set by client.
1.561 + All changed fields in the element are modified in database on success.
1.562 + No fields are altered in the database if the function leaves
1.563 +
1.564 + Client can request to ignore access control flags by setting the attribute mask
1.565 + CMDBSession::SetAttributeMask()
1.566 + However, only fields that the client has capabilities to alter will be modified.in the database
1.567 + A request to modify data in an unauthorised area will cause the function to leave.with
1.568 + KErrPermissionDenied
1.569 +
1.570 + If field does not exist, the function will leave with
1.571 + KErrNotFound [VCT - surely not]
1.572 +
1.573 + May also leave with other general error codes if there are unexpected
1.574 + problems (e.g. KErrNoMemory when out of memory)
1.575 +
1.576 + On failure, the container should be discarded or repopulated before it is used again
1.577 +
1.578 + @pre
1.579 +
1.580 + Populate this container with valid data for storage
1.581 + Ensure the ElementId for this container fully identifies the target data in the database
1.582 + <Table><Column><Record>
1.583 + Ensure that the session object has been initialised with the correct dataset version
1.584 + Ensure that the session object has appropriate access control attributes to manage the target data in the database
1.585 + @publishedAll
1.586 + */
1.587 + IMPORT_C void ModifyL(CMDBSession& aSession);
1.588 +
1.589 +
1.590 + /**
1.591 + Delete fields from the database.
1.592 +
1.593 + Client can request to ignore access control flags by setting the attribute mask,
1.594 + but only fields that the client has capabilities to delete will be removed.
1.595 +
1.596 + A request to delete data in unauthorised area will cause the function to leave
1.597 +
1.598 + @leave If client not authorised to read or write the data, will leave with
1.599 + KErrPermissionDenied
1.600 + May also leave with other general error codes if there are unexpected
1.601 + problems (e.g. KErrNoMemory when out of memory)
1.602 +
1.603 + @pre Ensure the ElementId for this container fully identifies the target data in the database
1.604 + <Table><Column><Record>
1.605 + Ensure that the session object has appropriate access control attributes to manage the target data in the database
1.606 + Ensure the ElementId for this container correcty identifies the target data in the database
1.607 +
1.608 + @publishedAll
1.609 + */
1.610 + IMPORT_C void DeleteL(CMDBSession& aSession);
1.611 +
1.612 +
1.613 + /**
1.614 + RequestNotification - Register for notification of events from all clients of the database
1.615 +
1.616 + aRequestStatus will be completed when the following events occur
1.617 + TransactionComplete
1.618 + TransactionRollback
1.619 + SessionClose
1.620 +
1.621 + this aRequestStatus can be cancelled by a call to
1.622 +
1.623 + MMetaDatabase::CancelNotification
1.624 +
1.625 + all outstanding aRequestStatus can be cancelled by a call to
1.626 +
1.627 + CMDBSession::CancelAllNotifications
1.628 +
1.629 + @capability WriteDeviceData
1.630 +
1.631 + @return KErrNone on success. A system wide error on failure
1.632 +
1.633 + @params aSession a valid session object
1.634 + @params aRequestStatus the requestStatus object that will be completed on notification
1.635 +
1.636 + @pre None
1.637 + @post A notification request will be outstanding
1.638 +
1.639 + @publishedAll
1.640 + */
1.641 + IMPORT_C TInt RequestNotification(CMDBSession& aSession,
1.642 + TRequestStatus& aRequestStatus);
1.643 +
1.644 + /**
1.645 + CancelNotification - cancel an outstanding notification request
1.646 +
1.647 + note that all outstanding notification requests can be cancelled by a call to
1.648 +
1.649 + CMDBSession::CancelAllNotifications
1.650 +
1.651 + @pres
1.652 +
1.653 + There is an outstanding notification request
1.654 +
1.655 + @publishedAll
1.656 + */
1.657 + IMPORT_C TInt CancelNotification(CMDBSession& aSession,
1.658 + TRequestStatus& aRequestStatus);
1.659 +
1.660 +
1.661 +protected:
1.662 +
1.663 +
1.664 + explicit MMetaDatabase();
1.665 +
1.666 +private:
1.667 +
1.668 + /*
1.669 + @internalComponent
1.670 + */
1.671 + void DoLoadL(CMDBSessionImpl* aSession, CMDBElement* aElement, CMDBElement* aMapper, TInt& aErr, TMDBElementId aRecordId, TMDBElementId aAttributes);
1.672 +
1.673 + /*
1.674 + @internalComponent
1.675 + */
1.676 + void DoLoadL(CMDBSessionImpl* aSession, CMDBElement* aElement, CMDBElement* aMapper, TInt& aErr, TMDBElementId aRecordId, TMDBElementId aAttributes, RArray<TUint32>& aMatches);
1.677 +
1.678 + /*
1.679 + @internalComponent
1.680 + */
1.681 + void DoFindL(CMDBSessionImpl* aSession, CMDBElement* aElement, CMDBElement* aMapper, TInt& aErr, RArray<TUint32>& candidates, RArray<TUint32>& matches);
1.682 +
1.683 + /*
1.684 + @internalComponent
1.685 + */
1.686 + void DoRefreshL(CMDBSessionImpl* aSession, CMDBElement* aElement, CMDBElement* aMapper, TInt &aErr);
1.687 +
1.688 + /*
1.689 + @internalComponent
1.690 + */
1.691 + void DoStoreL(CMDBSessionImpl* aSession, CMDBElement* aElement, CMDBElement* aMapper, TInt &aErr);
1.692 +
1.693 + /*
1.694 + @internalComponent
1.695 + */
1.696 + void DoModifyL(CMDBSessionImpl* aSession, CMDBElement* aElement, CMDBElement* aMapper, TInt &aErr);
1.697 +
1.698 +};
1.699 +
1.700 +
1.701 +
1.702 +
1.703 +
1.704 +class CMDBElement : public CBase, public MMetaDatabase
1.705 +/*
1.706 +Every item stored in the database is represented as a CMDBElement
1.707 +This class contains the id and attributes of every item in the database
1.708 +and for individual fields it also contains the value.
1.709 +
1.710 +@publishedAll
1.711 +@released
1.712 +*/
1.713 +{
1.714 +public:
1.715 +
1.716 +
1.717 + /**
1.718 + Default Constructor
1.719 +
1.720 + @publishedAll
1.721 + */
1.722 + IMPORT_C CMDBElement();
1.723 +
1.724 +
1.725 + /**
1.726 + Constructor
1.727 +
1.728 + @publishedAll
1.729 + */
1.730 + IMPORT_C CMDBElement(TMDBElementId aElementId);
1.731 +
1.732 +
1.733 + /**
1.734 + Destructor
1.735 +
1.736 + @publishedAll
1.737 + */
1.738 + IMPORT_C ~CMDBElement();
1.739 +
1.740 +
1.741 + // Accessors
1.742 +
1.743 + /**
1.744 + Returns the ElementId of an object of this type.
1.745 +
1.746 + The TypeId is
1.747 +
1.748 + <TableId><ColumnId><RecordId>
1.749 +
1.750 + This identifies the meaning of the field in the database schema
1.751 + It also identifies the type of the data stored in this element
1.752 + and the instance of the type
1.753 +
1.754 + @publishedAll
1.755 + */
1.756 + IMPORT_C TMDBElementId ElementId() const;
1.757 +
1.758 +
1.759 + /**
1.760 + Returns the TypeId of an object of this type.
1.761 +
1.762 + The TypeId is
1.763 +
1.764 + <TableId><ColumnId><x>
1.765 +
1.766 + This identifies the meaning of the data in this element in the database schema
1.767 + It also identifies the type of the data contained in this element
1.768 +
1.769 + For an element that is a Table or a Record, the ColumnId field will be set to
1.770 +
1.771 + KCDMaxColumnId
1.772 + @publishedAll
1.773 + */
1.774 + IMPORT_C TMDBElementId TypeId() const;
1.775 +
1.776 +
1.777 + /**
1.778 + Returns the TableId of an object of this type.
1.779 +
1.780 + The TableId is part of the ElementId
1.781 +
1.782 + <TableId><x><x>
1.783 +
1.784 + It identifies the table in the database that holds the data contained in this element
1.785 +
1.786 + @publishedAll
1.787 + */
1.788 + IMPORT_C TMDBElementId TableId() const;
1.789 +
1.790 +
1.791 + /**
1.792 + Returns the RecordId of an object of this type.
1.793 +
1.794 + The RecordId is part of the ElementId <x><x><RecordId>
1.795 +
1.796 + It identifies a particular instance of this type of Element in the database
1.797 +
1.798 + @publishedAll
1.799 + */
1.800 + IMPORT_C TInt RecordId() const;
1.801 +
1.802 +
1.803 + /**
1.804 + Returns the Attributes of an object of this type.
1.805 +
1.806 + Attributes express database access rights for the data of this element
1.807 +
1.808 + @publishedAll
1.809 + */
1.810 + IMPORT_C TMDBAttributeFlags Attributes() const;
1.811 +
1.812 + // SETTER FUNCTIONS
1.813 +
1.814 + /**
1.815 + Sets the ElementId
1.816 +
1.817 + @publishedAll
1.818 + */
1.819 + IMPORT_C void SetElementId(TMDBElementId aElementId);
1.820 +
1.821 +
1.822 + /**
1.823 + Sets the TypeId
1.824 +
1.825 + @publishedAll
1.826 + */
1.827 + IMPORT_C void SetTypeId(TMDBElementId aElementId);
1.828 +
1.829 +
1.830 + /**
1.831 + Sets the RecordId
1.832 +
1.833 + @publishedAll
1.834 + */
1.835 + IMPORT_C void SetRecordId(TInt aRecordId);
1.836 +
1.837 +
1.838 + /**
1.839 + Sets one or more attributes
1.840 +
1.841 + @publishedAll
1.842 + */
1.843 + IMPORT_C void SetAttributes(TMDBAttributeFlags aAttributes);
1.844 +
1.845 +
1.846 + /**
1.847 + Clears one or more attributes
1.848 +
1.849 + @publishedAll
1.850 + */
1.851 + IMPORT_C void ClearAttributes(TMDBAttributeFlags aAttributes);
1.852 +
1.853 +
1.854 + /**
1.855 + Queries the attributes
1.856 +
1.857 + Returns ETrue if all queried attributes are set
1.858 + Returns EFalse if any queried attribute is not set.
1.859 +
1.860 + @publishedAll
1.861 + */
1.862 + IMPORT_C TBool IsSetAttribute(TMDBAttributeFlags aAttributes) const;
1.863 +
1.864 +
1.865 + /**
1.866 + Queries the state of the field value
1.867 +
1.868 + Returns ETrue if the value of the element is not set
1.869 + Returns EFalse if the element contains a value
1.870 +
1.871 + @publishedAll
1.872 + */
1.873 + IMPORT_C TBool IsNull() const;
1.874 +
1.875 +
1.876 +
1.877 + EXP_DATA_VTABLE
1.878 +
1.879 + /**
1.880 + Queries the type of the field value
1.881 +
1.882 + Returns the enumeration TCDFieldValueTypes that represents the value that can be stored in this element
1.883 +
1.884 + @publishedAll
1.885 + */
1.886 +
1.887 + virtual TCDFieldValueTypes Type()=0;
1.888 +
1.889 + /**
1.890 + @internalComponent
1.891 + */
1.892 + TMDBElementId* Data(){return &iElementId;}
1.893 +
1.894 + /**
1.895 + @internalComponent
1.896 + */
1.897 + const TMDBElementId* CData(){return &iElementId;}
1.898 +
1.899 +
1.900 +
1.901 +protected:
1.902 +
1.903 + TMDBElementId iElementId;
1.904 +
1.905 + TAny* iValue;
1.906 +
1.907 + };
1.908 +
1.909 +
1.910 +
1.911 +
1.912 +///////////////////////////////////////////////////////////////////////////////////////
1.913 +// COMMSDAT CONTAINERS
1.914 +//
1.915 +
1.916 +/**
1.917 +Commsdat Container classes qualifying numeric values
1.918 +@internalComponent
1.919 +*/
1.920 +class CMDBNumFieldBase : public CMDBElement
1.921 +{
1.922 +public:
1.923 + /**
1.924 + Default Constructor
1.925 + */
1.926 + IMPORT_C CMDBNumFieldBase();
1.927 +
1.928 +
1.929 + /**
1.930 + Constructor setting Field's ElementId
1.931 + */
1.932 + IMPORT_C CMDBNumFieldBase(TMDBElementId aFieldId);
1.933 +
1.934 +
1.935 + /**
1.936 + Assignment operator for field value
1.937 + */
1.938 + IMPORT_C CMDBNumFieldBase& operator=(const TInt aValue);
1.939 +
1.940 + IMPORT_C void SetMaxLengthL(TInt aLength);
1.941 + TMDBElementId GetL();
1.942 +
1.943 + EXP_DATA_VTABLE
1.944 +
1.945 + virtual TCDFieldValueTypes Type()
1.946 + {
1.947 + return EInt;
1.948 + }
1.949 +
1.950 +};
1.951 +
1.952 +template<class TYPE>
1.953 +class CMDBField : public CMDBNumFieldBase
1.954 +/**
1.955 +A thin template that guards typed data access in a single CMDBElement
1.956 +This class describes a single numeric field in the database
1.957 +
1.958 +@publishedAll
1.959 +*/
1.960 +{
1.961 +public:
1.962 +
1.963 + /**
1.964 + Default Constructor
1.965 +
1.966 + @publishedAll
1.967 + */
1.968 + inline CMDBField()
1.969 + {
1.970 + }
1.971 +
1.972 + /**
1.973 + Constructor setting Field's ElementId
1.974 +
1.975 + @publishedAll
1.976 + */
1.977 + inline CMDBField(TMDBElementId aFieldId)
1.978 + : CMDBNumFieldBase(aFieldId)
1.979 + {
1.980 + }
1.981 +
1.982 +
1.983 + /**
1.984 + Assignment operator for field value
1.985 +
1.986 + @publishedAll
1.987 + */
1.988 + inline CMDBField<TYPE>& operator=(const TYPE& aValue)
1.989 + {
1.990 + return (CMDBField<TYPE>&)CMDBNumFieldBase::operator=((TInt&)aValue);
1.991 + }
1.992 +
1.993 +
1.994 + inline CMDBField<TYPE>& operator=(const CMDBField<TYPE>& aValue)
1.995 + {
1.996 + return (CMDBField<TYPE>&)CMDBNumFieldBase::operator=(aValue);
1.997 + }
1.998 +
1.999 + /**
1.1000 + Conversion operator for field value
1.1001 +
1.1002 + @publishedAll
1.1003 + */
1.1004 + inline operator TYPE&()
1.1005 + {
1.1006 + return (TYPE&)iValue;
1.1007 + }
1.1008 +
1.1009 + /**
1.1010 + Conversion operator for field value
1.1011 +
1.1012 + @publishedAll
1.1013 + */
1.1014 + inline CMDBField<TYPE>& GetL()
1.1015 + {
1.1016 + if(IsNull() && !(ElementId() & KCDChangedFlag))
1.1017 + {
1.1018 + User::Leave(KErrNotFound); //todo commsdat specific error code
1.1019 + }
1.1020 +
1.1021 + return (TYPE&)iValue;
1.1022 + }
1.1023 +
1.1024 + /**
1.1025 + Function for setting a value
1.1026 +
1.1027 + @publishedAll
1.1028 + */
1.1029 + inline void SetL(const TYPE& aValue)
1.1030 + {
1.1031 + CMDBNumFieldBase::operator=(aValue);
1.1032 + }
1.1033 +
1.1034 +};
1.1035 +
1.1036 +
1.1037 +
1.1038 +//////////////////
1.1039 +/**
1.1040 +Base Container class qualifying a text field
1.1041 +@internalComponent
1.1042 +*/
1.1043 +class CMDBTextFieldBase : public CMDBElement
1.1044 +{
1.1045 +public:
1.1046 + /**
1.1047 + Default Constructor
1.1048 + */
1.1049 + IMPORT_C CMDBTextFieldBase();
1.1050 +
1.1051 + /**
1.1052 + Constructor setting Field's ElementId
1.1053 + */
1.1054 + IMPORT_C CMDBTextFieldBase(TMDBElementId aFieldId);
1.1055 +
1.1056 +
1.1057 + /**
1.1058 + Destructor that deletes the field value
1.1059 + */
1.1060 + IMPORT_C ~CMDBTextFieldBase();
1.1061 +
1.1062 +
1.1063 + /**
1.1064 + Assignment Operator setting Field's value
1.1065 + */
1.1066 + IMPORT_C CMDBTextFieldBase& operator=(const TDesC& aValue);
1.1067 +
1.1068 +
1.1069 + IMPORT_C void SetMaxLengthL(TInt aLength);
1.1070 +
1.1071 + EXP_DATA_VTABLE
1.1072 +
1.1073 + virtual TCDFieldValueTypes Type()
1.1074 + {
1.1075 + return EText;
1.1076 + }
1.1077 +
1.1078 +};
1.1079 +
1.1080 +
1.1081 +
1.1082 +
1.1083 +
1.1084 +
1.1085 +
1.1086 +template<>
1.1087 +class CMDBField<TDesC> : public CMDBTextFieldBase
1.1088 +/**
1.1089 +A thin template that guards typed data access in a single CMDBElement
1.1090 +This class describes a single field in the database
1.1091 +
1.1092 +@publishedAll
1.1093 +*/
1.1094 +{
1.1095 +public:
1.1096 +
1.1097 + /**
1.1098 + Default Constructor
1.1099 +
1.1100 + @publishedAll
1.1101 + */
1.1102 + inline CMDBField()
1.1103 + {
1.1104 + }
1.1105 +
1.1106 + /**
1.1107 + Constructor setting Field's ElementId
1.1108 +
1.1109 + @publishedAll
1.1110 + */
1.1111 + inline CMDBField(TMDBElementId aFieldId)
1.1112 + : CMDBTextFieldBase(aFieldId)
1.1113 + {
1.1114 + }
1.1115 +
1.1116 +
1.1117 + inline void SetMaxLengthL(TInt aLength)
1.1118 + // create a new buffer if necessary.
1.1119 + {
1.1120 + CMDBTextFieldBase::SetMaxLengthL(aLength);
1.1121 + }
1.1122 +
1.1123 + inline CMDBField<TDesC>& operator=(const TDesC& aValue)
1.1124 + {
1.1125 + CMDBTextFieldBase::operator=(aValue);
1.1126 + return *this;
1.1127 + }
1.1128 +
1.1129 + inline CMDBField<TDesC>& operator=(CMDBField<TDesC>& aValue)
1.1130 + {
1.1131 + CMDBTextFieldBase::operator=((const TDesC&)aValue);
1.1132 + return *this;
1.1133 + }
1.1134 +
1.1135 + /**
1.1136 + Conversion operator for field value
1.1137 +
1.1138 + @publishedAll
1.1139 + */
1.1140 + inline operator const TDesC&()
1.1141 + {
1.1142 + if (! iValue)
1.1143 + return KNullDesC;
1.1144 +
1.1145 + return *(HBufC*)iValue;
1.1146 + }
1.1147 +
1.1148 + /**
1.1149 + Conversion operator for field value
1.1150 +
1.1151 + @publishedAll
1.1152 + */
1.1153 + inline TDesC& GetL()
1.1154 + {
1.1155 + if(IsNull() && !(ElementId() & KCDChangedFlag))
1.1156 + {
1.1157 + User::Leave(KErrNotFound); //todo commsdat specific error code
1.1158 + }
1.1159 +
1.1160 + return *(HBufC*)iValue;
1.1161 + }
1.1162 +
1.1163 + /**
1.1164 + Function for setting a value
1.1165 +
1.1166 + @publishedAll
1.1167 + */
1.1168 + inline void SetL(const TDesC& aValue)
1.1169 + {
1.1170 + SetMaxLengthL(aValue.Length());
1.1171 + CMDBTextFieldBase::operator=(aValue);
1.1172 + }
1.1173 +
1.1174 +
1.1175 +};
1.1176 +
1.1177 +
1.1178 +//////////////////
1.1179 +/**
1.1180 +Container class for qualifying binary values
1.1181 +@internalComponent
1.1182 +*/
1.1183 +class CMDBBinFieldBase : public CMDBElement
1.1184 +{
1.1185 +public:
1.1186 + /**
1.1187 + Default Constructor
1.1188 + */
1.1189 + IMPORT_C CMDBBinFieldBase();
1.1190 +
1.1191 +
1.1192 + /**
1.1193 + Constructor setting Field's ElementId
1.1194 + */
1.1195 + IMPORT_C CMDBBinFieldBase(TMDBElementId aFieldId);
1.1196 +
1.1197 +
1.1198 + /**
1.1199 + Destructor that deletes the field value
1.1200 + */
1.1201 + IMPORT_C ~CMDBBinFieldBase();
1.1202 +
1.1203 +
1.1204 + /**
1.1205 + Assignment Operator setting Field's value
1.1206 + */
1.1207 + IMPORT_C CMDBBinFieldBase& operator=(const TDesC8& aValue);
1.1208 +
1.1209 + /**
1.1210 + To allocate space for field data.
1.1211 + */
1.1212 + IMPORT_C void SetMaxLengthL(TInt aLength);
1.1213 +
1.1214 + EXP_DATA_VTABLE
1.1215 +
1.1216 + virtual TCDFieldValueTypes Type()
1.1217 + {
1.1218 + return EDesC8;
1.1219 + }
1.1220 +};
1.1221 +
1.1222 +
1.1223 +template<>
1.1224 +class CMDBField<TDesC8> : public CMDBBinFieldBase
1.1225 +/**
1.1226 +A thin template that guards typed data access in a single CMDBElement
1.1227 +This class describes a single field in the database
1.1228 +
1.1229 +@publishedAll
1.1230 +*/
1.1231 +{
1.1232 +public:
1.1233 +
1.1234 + /**
1.1235 + Default Constructor
1.1236 +
1.1237 + @publishedAll
1.1238 + */
1.1239 + inline CMDBField()
1.1240 + {
1.1241 + }
1.1242 +
1.1243 + /**
1.1244 + Constructor setting Field's ElementId
1.1245 +
1.1246 + @publishedAll
1.1247 + */
1.1248 + inline CMDBField(TMDBElementId aFieldId)
1.1249 + : CMDBBinFieldBase(aFieldId)
1.1250 + {
1.1251 + }
1.1252 +
1.1253 + inline void SetMaxLengthL(TInt aLength)
1.1254 + // create a new buffer if necessary.
1.1255 + {
1.1256 + CMDBBinFieldBase::SetMaxLengthL(aLength);
1.1257 + }
1.1258 +
1.1259 +
1.1260 + inline CMDBField<TDesC8>& operator=(const TDesC8& aValue)
1.1261 + {
1.1262 + return (CMDBField<TDesC8>&)CMDBBinFieldBase::operator=(aValue);
1.1263 + }
1.1264 +
1.1265 +
1.1266 + inline CMDBField<TDesC8>& operator=(CMDBField<TDesC8>& aValue)
1.1267 + // Copy assignment
1.1268 + {
1.1269 + return (CMDBField<TDesC8>&)CMDBBinFieldBase::operator=((const TDesC8&)aValue);
1.1270 + }
1.1271 +
1.1272 +
1.1273 + /**
1.1274 + Conversion operator for field value
1.1275 +
1.1276 + @publishedAll
1.1277 + */
1.1278 + inline operator const TDesC8&()
1.1279 + {
1.1280 + if (! iValue)
1.1281 + return KNullDesC8;
1.1282 +
1.1283 + return *(HBufC8*)iValue;
1.1284 + }
1.1285 +
1.1286 + /**
1.1287 + Conversion operator for field value
1.1288 +
1.1289 + @publishedAll
1.1290 + */
1.1291 + inline TDesC8& GetL()
1.1292 + {
1.1293 + if(IsNull() && !(ElementId() & KCDChangedFlag))
1.1294 + {
1.1295 + User::Leave(KErrNotFound); //todo commsdat specific error code
1.1296 + }
1.1297 +
1.1298 + return *(HBufC8*)iValue;
1.1299 + }
1.1300 +
1.1301 + /**
1.1302 + Function for setting a value
1.1303 +
1.1304 + @publishedAll
1.1305 + */
1.1306 + inline void SetL(const TDesC8& aValue)
1.1307 + {
1.1308 + SetMaxLengthL(aValue.Length());
1.1309 + CMDBBinFieldBase::operator=(aValue);
1.1310 + }
1.1311 +
1.1312 +};
1.1313 +
1.1314 +
1.1315 +
1.1316 +///////////////////////////////////////////////////////////////////////////////////////////////
1.1317 +
1.1318 +/**
1.1319 +Base class for CMDBRecordLink
1.1320 +@internalComponent
1.1321 +*/
1.1322 +class CMDBRecordLinkBase : public CMDBNumFieldBase
1.1323 +{
1.1324 +public :
1.1325 +
1.1326 + IMPORT_C CMDBRecordLinkBase();
1.1327 +
1.1328 + IMPORT_C CMDBRecordLinkBase(TMDBElementId aLinkingFieldId);
1.1329 +
1.1330 + IMPORT_C CMDBRecordLinkBase(TMDBElementId aLinkingFieldId, CMDBElement* aLinkedRecord);
1.1331 +
1.1332 +
1.1333 + IMPORT_C ~CMDBRecordLinkBase();
1.1334 +
1.1335 + /**
1.1336 + Assignment operator for field value
1.1337 + which sets the id of the element list
1.1338 + */
1.1339 + IMPORT_C CMDBRecordLinkBase& operator=(const TMDBElementId aValue);
1.1340 +
1.1341 +
1.1342 + /**
1.1343 + Conversion operator for field value
1.1344 + which gets the id of the element list
1.1345 + */
1.1346 + IMPORT_C operator TMDBElementId();
1.1347 +
1.1348 + TCDFieldValueTypes Type()
1.1349 + {
1.1350 + return ELink;
1.1351 + }
1.1352 +
1.1353 +protected:
1.1354 +
1.1355 + EXP_DATA_VTABLE
1.1356 +
1.1357 +public:
1.1358 +
1.1359 + // the record referenced by the link id stored in the value of this field.
1.1360 + CMDBElement* iLinkedRecord;
1.1361 +
1.1362 +};
1.1363 +
1.1364 +
1.1365 +template<class RECORD_TYPE>
1.1366 +class CMDBRecordLink : public CMDBRecordLinkBase
1.1367 +/**
1.1368 + This container expresses a 'soft-link' to a record in another table.
1.1369 +
1.1370 + The value of a CMDBRecordLink field as stored in the database is the
1.1371 + ElementId (<Table><Record>) of the linked record.
1.1372 +
1.1373 + The linked record itself can be viewed via the iLinkedRecord member and its accessors
1.1374 +
1.1375 + iLinkedRecord must be created explicitly by the client - either on construction,
1.1376 + or by use of the CreateLinkL or SetLinkL functions. Often the linked record is not
1.1377 + required by a caller. So creating it automatically would just waste memory
1.1378 +
1.1379 + When instantiating iLinkedRecord directly take care to match the object's type to the Type
1.1380 + ID that will be found at the linking element. It is better to use the CreateLinkL or
1.1381 + SetLinkL functions to ensure type safety
1.1382 +
1.1383 + Calling MMetaDatabase functions on a CMDRecordLink field directly will perform the operation
1.1384 + on the field and also the linked record if it is present
1.1385 +@publishedAll
1.1386 +@released
1.1387 +*/
1.1388 +{
1.1389 +public :
1.1390 + /**
1.1391 + Constructor/Destructor
1.1392 +
1.1393 + @publishedAll
1.1394 + */
1.1395 +
1.1396 + inline CMDBRecordLink()
1.1397 + : CMDBRecordLinkBase() {}
1.1398 +
1.1399 + /**
1.1400 + Constructor
1.1401 +
1.1402 + @publishedAll
1.1403 + */
1.1404 + inline CMDBRecordLink(TMDBElementId aLinkingFieldId)
1.1405 + : CMDBRecordLinkBase(aLinkingFieldId) {}
1.1406 +
1.1407 + /**
1.1408 + Constructor
1.1409 +
1.1410 + @publishedAll
1.1411 + */
1.1412 + inline CMDBRecordLink(TMDBElementId aLinkingFieldId, RECORD_TYPE* aLinkedRecord)
1.1413 + : CMDBRecordLinkBase(aLinkingFieldId, (CMDBElement*)aLinkedRecord) {}
1.1414 +
1.1415 + /**
1.1416 + @publishedAll
1.1417 + */
1.1418 + inline CMDBRecordLink& operator=(const TMDBElementId aValue)
1.1419 + {
1.1420 + return (CMDBRecordLink&)CMDBRecordLinkBase::operator=(aValue);
1.1421 + }
1.1422 +
1.1423 +
1.1424 + // SETTERS
1.1425 +
1.1426 + /**
1.1427 + Set the field value (this will be validated on StoreL)
1.1428 +
1.1429 + @publishedAll
1.1430 + */
1.1431 + inline void SetL(const TMDBElementId aValue)
1.1432 + {
1.1433 + CMDBRecordLinkBase::operator=(aValue);
1.1434 + }
1.1435 +
1.1436 +
1.1437 + // OPERATORS
1.1438 +
1.1439 + /**
1.1440 + conversion operator for linked record of this type
1.1441 +
1.1442 + @publishedAll
1.1443 + */
1.1444 + inline operator RECORD_TYPE*()
1.1445 + {
1.1446 + return static_cast<RECORD_TYPE*>(iLinkedRecord);
1.1447 + }
1.1448 +
1.1449 +};
1.1450 +
1.1451 +enum TFieldTypeAttributes
1.1452 +/**
1.1453 +To express type information for all MetaDatabase fields
1.1454 +@publishedAll
1.1455 +@released
1.1456 +*/
1.1457 + {
1.1458 + ENoAttrs, ///< No attributes associated with this field.
1.1459 + ENotNull, ///< Ensures the field contains a value and must not be null.
1.1460 + };
1.1461 +
1.1462 +typedef struct
1.1463 +/**
1.1464 +To express type information for all MetaDatabase fields
1.1465 +@publishedAll
1.1466 +@released
1.1467 +*/
1.1468 + {
1.1469 + const TMDBElementId iTypeId; ///< Identifier for the field.
1.1470 + const TInt iValType; ///< The field type value e.g.EText, EMedText.
1.1471 + const TFieldTypeAttributes iTypeAttr; ///< The field attribute, either ENoAttrs or ENotNull.
1.1472 + const TText * const iTypeName; ///< Name of the field type.
1.1473 +
1.1474 + } SRecordTypeInfo;
1.1475 +
1.1476 +
1.1477 +#define MDB_GENERIC_TYPE_INFO(a, b, c, d) SGenericRecordTypeInfo(a, b, c, d)
1.1478 +
1.1479 +typedef TBuf<64> TGenericTypeName;
1.1480 +
1.1481 +typedef struct SGenericRecordTypeInfoTag
1.1482 +/**
1.1483 +To express type information for all MetaDatabase fields
1.1484 +@publishedAll
1.1485 +@released
1.1486 +*/
1.1487 + {
1.1488 + SGenericRecordTypeInfoTag()
1.1489 + : iTypeId(0), iValType(0), iTypeAttr(ENoAttrs) {}
1.1490 +
1.1491 + SGenericRecordTypeInfoTag(TMDBElementId aId,
1.1492 + TInt aVal,
1.1493 + TFieldTypeAttributes aAttrType)
1.1494 + : iTypeId(aId), iValType(aVal), iTypeAttr(aAttrType)
1.1495 + {
1.1496 + }
1.1497 +
1.1498 + SGenericRecordTypeInfoTag(TMDBElementId aId,
1.1499 + TInt aVal,
1.1500 + TFieldTypeAttributes aAttrType,
1.1501 + TText * const aTypeName)
1.1502 + : iTypeId(aId), iValType(aVal), iTypeAttr(aAttrType), iTypeName(aTypeName)
1.1503 + {
1.1504 +
1.1505 + }
1.1506 +
1.1507 +
1.1508 + SGenericRecordTypeInfoTag( TMDBElementId aId,
1.1509 + TInt aVal,
1.1510 + TFieldTypeAttributes aAttrType,
1.1511 + const TGenericTypeName& aTypeName)
1.1512 + : iTypeId(aId), iValType(aVal), iTypeAttr(aAttrType), iTypeName(aTypeName) {}
1.1513 +
1.1514 +
1.1515 + TMDBElementId iTypeId; ///< Identifier for the field type.
1.1516 + TInt iValType; ///< The field type value e.g.EText, EMedText.
1.1517 + TFieldTypeAttributes iTypeAttr; ///< The type's attribute, either ENoAttrs or ENotNull
1.1518 + TGenericTypeName iTypeName; ///< Name of the field type.
1.1519 + } SGenericRecordTypeInfo;
1.1520 +
1.1521 +
1.1522 +
1.1523 +class CMDBRecordBase : public CMDBNumFieldBase
1.1524 +/**
1.1525 +Base class for all MetaDatabase records
1.1526 +@publishedAll
1.1527 +@released
1.1528 +*/
1.1529 + {
1.1530 + public:
1.1531 +
1.1532 + inline CMDBRecordBase(){}
1.1533 + inline CMDBRecordBase(TMDBElementId aElementId)
1.1534 + : CMDBNumFieldBase(aElementId | KCDMaskShowFieldType){}
1.1535 +
1.1536 + IMPORT_C virtual CMDBElement* GetFieldByNameL(const TPtrC& aFieldName, TInt& aValType );
1.1537 +
1.1538 + IMPORT_C virtual CMDBElement* GetFieldByIdL(TMDBElementId aId);
1.1539 +
1.1540 + IMPORT_C virtual const SRecordTypeInfo* GetRecordInfo();
1.1541 +
1.1542 + };
1.1543 +
1.1544 +
1.1545 +
1.1546 +class CMDBGenericRecord : public CMDBRecordBase
1.1547 +/**
1.1548 +Container for data and type information in a MetaDatabase record
1.1549 +For use to contain user-defined records as an alternative to declaring a
1.1550 +specific record class of type CCDRecordBase
1.1551 +
1.1552 +@publishedAll
1.1553 +@released
1.1554 +*/
1.1555 + {
1.1556 +friend class TMDBGenericRecordVisitor;
1.1557 +friend class CMDBSessionImpl;
1.1558 + public:
1.1559 +
1.1560 +
1.1561 + EXP_DATA_VTABLE
1.1562 +
1.1563 + explicit inline CMDBGenericRecord(TMDBElementId aElementId)
1.1564 + : CMDBRecordBase(aElementId) {}
1.1565 +
1.1566 + IMPORT_C ~CMDBGenericRecord();
1.1567 +
1.1568 + IMPORT_C virtual CMDBElement* GetFieldByNameL(const TPtrC& aFieldName, TInt& aValType );
1.1569 +
1.1570 + IMPORT_C CMDBElement* GetFieldByIdL(TMDBElementId aId);
1.1571 +
1.1572 +
1.1573 + IMPORT_C void InitializeL(const TDesC& aTableName, const SGenericRecordTypeInfo* aNewTableInfo);
1.1574 +
1.1575 +
1.1576 + private:
1.1577 +
1.1578 + /*
1.1579 + The name of this record type
1.1580 + */
1.1581 + TBuf<KCDMaxFieldNameLength> iRecordType;
1.1582 +
1.1583 + /*
1.1584 + array of type information about fields in this record
1.1585 + order of field info should match order of fields
1.1586 + */
1.1587 + RArray<SGenericRecordTypeInfo> iRecordInfo;
1.1588 + /*
1.1589 + array of fields in this record
1.1590 + order of fields should match order of field info
1.1591 + */
1.1592 + RPointerArray<CMDBElement> iFields;
1.1593 + };
1.1594 +
1.1595 +
1.1596 +
1.1597 +class CMDBRecordSetBase : public CMDBTextFieldBase
1.1598 +/**
1.1599 +Use this class to express a list of records MetaDatabase Element type
1.1600 +Records can be ordered using the standard RPointerArray functions
1.1601 +
1.1602 +@publishedAll
1.1603 +@released
1.1604 +*/
1.1605 + {
1.1606 + public:
1.1607 + /**
1.1608 + @internalComponent
1.1609 + */
1.1610 + IMPORT_C CMDBRecordSetBase();
1.1611 +
1.1612 + /**
1.1613 + @internalComponent
1.1614 + */
1.1615 + IMPORT_C CMDBRecordSetBase(TMDBElementId aElementId);
1.1616 +
1.1617 + /**
1.1618 + @internalComponent
1.1619 + */
1.1620 + IMPORT_C ~CMDBRecordSetBase();
1.1621 +
1.1622 + inline CMDBRecordSetBase& operator=(const TPtrC& aValue)
1.1623 + {
1.1624 + return (CMDBRecordSetBase&)CMDBTextFieldBase::operator=(aValue);
1.1625 + }
1.1626 +
1.1627 + protected:
1.1628 +
1.1629 + EXP_DATA_VTABLE
1.1630 +
1.1631 + public:
1.1632 +
1.1633 + RPointerArray<CMDBRecordBase> iRecords;
1.1634 +
1.1635 + };
1.1636 +
1.1637 +
1.1638 +
1.1639 +template <class TYPE>
1.1640 +class CMDBRecordSet : public CMDBRecordSetBase
1.1641 +/**
1.1642 +Use this class to express a list of records of a particular MetaDatabase Element type
1.1643 +Records can be ordered using the standard RPointerArray functions
1.1644 +
1.1645 +@publishedAll
1.1646 +*/
1.1647 +{
1.1648 +public:
1.1649 +
1.1650 + inline CMDBRecordSet(){}
1.1651 +
1.1652 + inline CMDBRecordSet(TMDBElementId aElementId)
1.1653 + : CMDBRecordSetBase(aElementId) {}
1.1654 +
1.1655 + inline CMDBRecordSet<TYPE>& operator=(const TPtrC& aValue)
1.1656 + {
1.1657 + return (CMDBRecordSet<TYPE>&)CMDBRecordSetBase::operator=(aValue);
1.1658 + }
1.1659 +
1.1660 + inline TYPE* operator [](const TInt i)
1.1661 + {
1.1662 + return (TYPE*)iRecords[i];
1.1663 + }
1.1664 +
1.1665 +private:
1.1666 +
1.1667 +};
1.1668 +
1.1669 +
1.1670 +
1.1671 +
1.1672 +} //end namespace CommsDat
1.1673 +
1.1674 +#endif // METADATABASE_H