-
Notifications
You must be signed in to change notification settings - Fork 4
codec implementation
To implement a codec into the tool chain the following steps have to be done:
- Implement a valid coder class
- Register a codec id
- Create a codec setting table
- Implement and link the codec
A valid coder in the toolchain extends the class AbstractCodec
(coder/codec/abstractCodec.py
). It was built as an abstract class via ABCMeta to ensure that the class can not be initialized by itself and that further more each codec implements all the following methods:
-
_get_codec_table_path()
: Returns the path of the codec's configuration file -
get_library_name()
: Returns the name of the library the codec is originally implemented in (must be callable on the command line!) -
_get_valid_field_names()
: Returns a list of valid field names which can be evaluated by the codec -
_validate_general_encoding_settings(encoding_settings)
: Validates if the given encoding settings can be integrated in the codec or if they will rise conflicts (throws in error in this case) -
get_settings_param_collection()
: Returns a param collection which can be used to dump it in a coder execution
The implementation of the methods has no guidlines, but it is necessary that it will perform the tasks described above. The name of the codec class should follow the scheme <CodecId>Codec
.
In the encoding settings for each configuration set a codec_id
can be configured. This id will enable the toolchain to associate it with the implemented codec, so that it can be used by the chain's tools. For this purpose it is necessary that a clear and unique codec id will be generated for the new coder. The codec id has to be registered in the codec list (coder/codec/codecList.py
) and in the wiki.
In addition to the codec id a codec setting id can be set in the encoding settings. These id is used to link further codec specific settings with the encoding settings. For this purpose it is mandantory to create in the config/codec-folder
a database with the name of the codec id. This database should follow the same rules than all other databases in this application do.
NOTE: Don't forget to update the wiki with a documentation about this new created codec settings table!
Finally a connection has to be made between the codec and it's id. This can be done in the function __get_codec
in coder/codecList.py
. The idea is that the codec class has to be imported ONLY IF it needs to be used. This will prevent useless redundant code imports. For that the following programming scheme has been established:
# <descriptive comment>
if codec_id == <CODEC_ID>:
from <codecName> import <CodecName>
return CodecName(<optional_arguments, ...>)