You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 lines
6.0 KiB

//Copyright 2020 Siemens Digital Industries Software
//==================================================
//Copyright $2016.
//Siemens Product Lifecycle Management Software Inc.
//All Rights Reserved.
//==================================================
//Copyright 2020 Siemens Digital Industries Software
/**
@file
PostActionInternalHandler is a Resource Acquisition Is Initialization (RAII) class for avoiding dulicate execution of savePostInternal.
<br/>Instances of this class need to be created/used <b>only</b> by the framework (e.g. auto-generated Dispatch mechanism(&lt;BO&gt;Dispatch::&lt;op&gt;) for a set-based Operation).
<br/>To facilitate the compilation of the auto-generated &lt;BO&gt;Dispatch::&lt;op&gt; operation, this class is made public.
<br/>This class and its members are not intended to be used explicitly for any other purpose.
<br/>As a consequence, there will be no support for issues stemming from creating instances of this class and calling its APIs explicitly.
*/
#ifndef POSTACTIONINTERNALHANDLER_HXX
#define POSTACTIONINTERNALHANDLER_HXX
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unidefs.h>
#include <extensionframework/OperationDispatcher.hxx>
#include <tccore/method.h>
#include <metaframework/libmetaframework_exports.h>
/** These options helpful to identify whether postActionInternal executed for the object, and so helpful to handle the combination of refactored/non-refactored BOs */
typedef enum PostActionExecutionOption_e
{
EXECUTE_ALL = 0, /**< Identifies to execute all postActions */
SKIP_POST_INTERNAL /**< Identifies to execute all postActions except internal postAction */
}PostActionExecutionOption_t;
namespace Teamcenter
{
class PostActionInternalHandler;
class BulkInput;
}
class METAFRAMEWORK_API Teamcenter::PostActionInternalHandler
{
public:
/** Constructor */
PostActionInternalHandler(
const std::string &opId, /**< (I) current operation ID */
const std::vector<Teamcenter::BulkInput*> *inputs /**< (I) BulkInputs participating in the current operation */
);
/** Destructor */
~PostActionInternalHandler();
/**
Sets the given postActionExecution option for inputs object tags in the context of input operation ID
*/
static void setPostActionExecutionOption(
const std::string &opId, /**< (I) current operation ID */
const std::vector < tag_t > &objs, /**< (I) object tags to set input Option with current operation */
PostActionExecutionOption_t option /**< (I) postAction execution option to set */
);
/**
gets the postActionExecution option of inputs object tag in the context of input operation ID
@returns
<ul>
<li>#PostActionExecutionOption_t of given input object tag
</ul>
*/
static PostActionExecutionOption_t getPostActionExecutionOption(
const std::string &opId, /**< (I) current operation ID */
const tag_t &obj /**< (I) object tag to get input Option with current operation */
);
/**
Adds the indicated function pointer to the set of registered high-priority post-actions for bulk save.
Types that have implemented both savePostinternal and a &lt;typename&gt;_fnd0Save_HighPriorityPostAction
use this function to prevent the framework from calling savePostInternal during bulk save.<br />
<br />@note Going forward, any BusinessObject that supports bulk save (e.g. overrides fnd0Save and/or returns true for
isSaveRectoredAsSetBased) that implements savePostInternal MUST also implement the equivalant set-based function,
&lt;typename&gt;_fnd0Save_HighPriorityPostAction.<br />
<br />Using this function to register a BusinessObject's fnd0Save_HighPriorityPostAction is a temporary necessity
until all existing BusinessObjects are refactored to conform to this pattern. When all BusinessObjects that
support bulk save and implement savePostInternal also have implemented &lt;typename&gt;_fnd0Save_HighPriorityPostAction,
this function will be removed.
*/
static void registerBulkSaveHiPriorityPostAction(
const METHOD_function_t &fn /**< (I) The function registered. */
);
/**
Returns true if the ExtensionFunctionSet of the OperationDispatcher provided contains a high-priority post-action registered
for bulk-save by #registerBulkSaveHiPriorityPostAction. This function is used internally to prevent the execution of both
&lt;typename&gt;_fnd0Save_HighPriorityPostAction and savePostInternal on the same object during bulk save execution.
@returns
<ul>
<li>true if the current OperationDispatcher contains a registered high-priority post-action.</li>
</ul>
*/
static bool isBulkSaveHiPriorityPostActionRegistered(
const OperationDispatcher* opDispatcher /**< (I) The OperationDispatcher to search. */
);
private:
/** restricting default constructor */
PostActionInternalHandler();
/**
Copy constructor and assignment operator declarations as private to restrict
*/
PostActionInternalHandler( const PostActionInternalHandler & other );
PostActionInternalHandler & operator=( const PostActionInternalHandler & other );
static std::map < std::string, std::map< tag_t, PostActionExecutionOption_t > > s_objPostActionExecutionMap; /**< Representing map of opId with map of object tag and postActionExecution option */
static std::set < METHOD_function_t > s_registeredHiPriPostActionFns;
std::set< tag_t > m_objs; /**< Representing Objects participating with current operation scope */
std::string m_opId; /**< Representing operation ID of current operation */
};
#include <metaframework/libmetaframework_undef.h>
#endif