WRAPPER_API bool Put[Type](const [Type] &value)
WRAPPER_API bool Put[Type](const [Type] &value, bool overwrite)
Above, [Type] is a placeholder for the class name of the desired object.
The DataSource has a 'Put' method for each type of object that can reside in the data source. The 'Put' method will add an item to the data source or change the value of an item in the data source. In order to add a new AngularUnit to the data source, one would use the PutAngularUnit method, and to add a new HorizontalDatum to the data source, one would use the PutHorizontalDatum method.
There are two signatures for the 'Put' methods. The first signature takes a single argument, which is the object to be put in the data source. If there exists an object in the data source with the same identifiers as the specified object, it will be overwritten. The second signature takes two arguments, the first of which is the object to be put in the data source, and the second of which is a boolean value indicating if an existing object in the data source should be overwritten to accommodate the specified object. A true value will overwrite an existing object with identifiers that match the specified object, and a false value will leave the existing object in the data source.
If the object being edited already exists in the base datasource and the Editable property is false, then this method will cause a GeoCalcException to be thrown with ErrorCode specifying FileReadOnly.
The signatures are different in the case of a Serializable object, where one must specify the ObjectType that corresponds to the type of the Serializable object. In order to put a Serializable into the data source and overwrite any existing objects, one would call PutSerializable specifying the ObjectType of the Serializable as the first argument, and the Serializable object to be put in the data source as the second argument. In order put a Serializable into the data source without overwriting an existing object, one would call PutSerializable, specifying the ObjectType of the Serializable as the first argument, the Serializable object to be put into the data source as the second argument, and a boolean value (false) indicating if an existing argument should be overwritten as the third argument.
The following example shows how to add an AngularUnit to the data source, but the usage is the same for all objects with the exception of Serializable.
void DataSource_Put(GEOCALCPBW_NAMESPACE::DataSource & data)
{
if(data.get_IsLoaded() && data.get_Editable())
{
GEOCALCPBW_NAMESPACE::AngularUnit au;
au.get_Identifiers().Add(_towchar("GC"), _towchar("A_Super_Great_AngularUnit"));
if(! data.PutAngularUnit(au, TRUE))
{
AfxMessageBox("PutAngularUnit failed");
}
}
}