Workspace 6.21.5
|
In this section, we're going to understand the code that was automatically generated by Workspace so that we know how to customise our enum if we need to change it in the future.
Rebuilding (continue on with tutorial Writing a Custom Enum )
If we look in our priority.h file, we'll see the standard header guards and a number of includes, most notably for "Workspace/DataExecution/DataObjects/enumtointadaptor.h". This is important and will be covered later. We also include our simpleplugin.h file, which gives us access to our export symbol (CSIRO_API), in order to make our enum visible to other plugins / DLLs if necessary.
Further down, we can see the definition of the enum itself, including the symbol names we entered, each of which is associated with a specific integer value. Our brief description is atop this definition.
Next, we see a template specialisation of the function, "getEnumNames". This function is what Workspace uses to identify the visible names associated with each enum value. It is critical that the number of names in this list matches the number of elements in the enum itself.
Finally, we see that the enum itself is declared as a Workspace Data Factory (see Writing a Workspace Datatype for more information), and then more interestingly, we see a special Enum To Int Adaptor is declared. This will allow Workspace to automatically convert the enum to an integer wherever this is required, such as in the case it is used to drive a DataExecution::SelectInput or similar operation.
Our source file is very straightforward. It contains only includes as well as the definition macros for our Workspace Data Factory and Enum To Int Adaptor.
Rebuilding (continue on with tutorial Writing a Custom Enum )
If we look at our simpleplugin.cpp file, we will see that the wizard has made a number of changes. The following code has been added to the setup() function.
These lines do the following and in the order specified:
If we look at our CMakeLists.txt file, we will see that the wizard will have made minimal changes. The priority header and source files have simply been added to the HEADERS, INSTALL_HEADERS and SOURCES lists, thus making them source files of our plugin.
Rebuilding (continue on with tutorial Writing a Custom Enum )