X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=include%2Fanna%2Fdiameter%2Fcodec%2FEngineImpl.hpp;h=b79aeb1428b3b049c290b145bb19b227a317c731;hb=b9cb59210ce2a02d8246f1a9a1acfcfdcd892f3a;hp=049906b7109b866d07afa596f206df61b2d76ed8;hpb=39033fd99e58e994a5e98c1060dcc79e0d81f9c9;p=anna.git diff --git a/include/anna/diameter/codec/EngineImpl.hpp b/include/anna/diameter/codec/EngineImpl.hpp index 049906b..b79aeb1 100644 --- a/include/anna/diameter/codec/EngineImpl.hpp +++ b/include/anna/diameter/codec/EngineImpl.hpp @@ -183,7 +183,7 @@ public: * Defines behaviour mode regarding when to validate a message: before encoding, after decoding (by default), always or never * Anyway validation procedure may be called at any moment (#valid) */ - struct ValidationMode { enum _v { BeforeCoding, AfterDecoding /* default */, Always, Never /* optimization */ }; }; + struct ValidationMode { enum _v { BeforeEncoding, AfterDecoding /* default */, Always, Never /* optimization */ }; }; /** * Defines behaviour mode regarding when to fix a message: before encoding (by default), after decoding, always or never. @@ -194,7 +194,7 @@ public: * hide any validation problem regarding Avps position at any level. * Anyway fix procedure may be called at any moment (#fix) */ - struct FixMode { enum _v { BeforeCoding /* default */, AfterDecoding, Always, Never /* optimization */ }; }; + struct FixMode { enum _v { BeforeEncoding /* default */, AfterDecoding, Always, Never /* optimization */ }; }; // Creators @@ -209,6 +209,8 @@ private: ValidationMode::_v a_validationMode; bool a_ignoreFlags; FixMode::_v a_fixMode; + bool a_selectStackWithApplicationId; // default behaviour: let the user switch the stack (false for this boolean) + // Auxiliary const stack::Dictionary * a_dictionary; @@ -231,6 +233,7 @@ public: virtual ~EngineImpl() {;} + // setters /** Sets diameter dictionary loaded at stack engine. It's recommended to configure a valid dictionary (if not, or NULL provided at #setDictionary, all avps will be managed as 'Unknown' format and all @@ -238,20 +241,45 @@ public: @param dictionary Diameter dictionary. At single threaded processes, the same codec engine could be used with different diameter dictionaries (multi-stack applications). In that case the process must switch the stack for - the whole decoding or enconding operation over a Message depending on the context. But the smart way implies - inherit from this engine creating a component for each diameter stack managed in the application. Inheritance - is mandatory in multi-threaded processes: one engine, a unique stack. + the whole decoding or enconding operation over a Message depending on the context (normally the message header + Application-Id is used as stack identifier). But the smart way implies inherit from this engine creating a + component for each diameter stack managed in the application. Inheritance is mandatory in multi-threaded processes: + one engine, a unique stack. */ void setDictionary(const stack::Dictionary * dictionary) throw() { a_dictionary = dictionary; } - // get /** * Sets diameter dictionary loaded at stack engine with the provided identifier. * - * @param stackId Stack identifier. When missing, default stack (stack::Engine::getDefaultStack()) will be used + * @param stackId Stack identifier. When missing, NULL will be returned * @return Returns configured dictionary (NULL if stack id was not found) */ - const stack::Dictionary *setDictionary(int stackId = -1) throw(); + const stack::Dictionary *setDictionary(unsigned int stackId) throw(); + + + /** + * By default, the user will select the appropiate stack id depending on the context (see #setDictionary), but + * some applications could consider interesting automatic stack selection based on managed messages (incoming + * decoded ones, or built messages to be encoded). By default, on engine construction, no changes are done. + * Multithreaded processes should have a unique codec engine for each managed stack (then you don't have to + * worry about), but mono processes with multistack implementation over the same-unique engine, should activate + * this to have the commonly recommended way to choose the stack: using the Application-Id value. + * + * @warning do not activate in case of multithreaded applications. + * @param enable Activates/deactivates the stack selection from the Application-Id value within the message header. + */ + void selectStackWithApplicationId (bool enable) throw() { a_selectStackWithApplicationId = enable; } + + // getters + + /** + Gets the currently configured behaviour regarding stack selection for multistack codec engines in mono thread + applications. + + @return True if selection is done with the Application-Id. False if no selection is performed (user responsibility). + */ + bool hasSelectStackWithApplicationId (void) throw() { return a_selectStackWithApplicationId; } + /** Gets currently configured dictionary. NULL if not configured (manual encode/decode operations).