//Copyright 2020 Siemens Digital Industries Software
//==================================================
//Copyright $2016.
//Siemens Product Lifecycle Management Software Inc.
//All Rights Reserved.
//==================================================
//Copyright 2020 Siemens Digital Industries Software

/** 
    @file 
    ManageBulkData is a Resource Acquisition Is Initialization (RAII) class for managing BulkData.
    <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 MANAGEBULKDATA_HXX
#define MANAGEBULKDATA_HXX

#include <string>
#include <vector>

#include <unidefs.h>

#include <metaframework/libmetaframework_exports.h>

namespace Teamcenter
{
    class ManageBulkData;
    class BulkData;
    class OperationObjectBatch;
    class OperationDispatcher;
    class BulkInput;
}

class METAFRAMEWORK_API Teamcenter::ManageBulkData
{
public:
    /** Constructor */ 
    ManageBulkData(
        const BulkData *bd,       /**< (I) Input BulkData information if applicable */
        const std::string &opId   /**< (I) current operation ID */
        );

    /** Destructor */ 
    virtual ~ManageBulkData();

    /** Retrieves the BulkData associated with this instance */ 
    BulkData * getBulkData() const;

    /**
        Performs Database actions for the objects collected in it's BulkData
        @returns
        <ul>
        <li>#ITK_ok on success
        </ul>
    */
    int saveDeleteUnlock();

    /**
        Performs Database actions for the objects collected in it's BulkData
        @returns
        <ul>
        <li>#ITK_ok on success
        </ul>
    */
    int saveDeleteUnlock(
        const std::string& opId                                             /**< (I) current operation ID */
        );

    /**
        Performs stacking of InputsVector objects & OperationDispatchers for postActions for operations if applicable with BulkData
        @returns
        <ul>
        <li>@c true if stacking of postActions is done
        <li>@c false if stacking of postAction is not done
        </ul>
    */
    bool stackPostActions(
        const std::vector< Teamcenter::OperationObjectBatch* >&  batches,   /**< (I) The OperationObjectBatches which need to stacked for current operation */
        const std::string& opId                                             /**< (I) current operation ID */
        );

    /**
        Gets stacked InputsVector objects & OperationDispatchers for postActions for operations if applicable from BullkData
    */
    int getPostActionsData(
        std::vector<Teamcenter::OperationDispatcher*> &opDispVec,           /**< (O) The vector of OperationDispatcher for the inputs to execute postActions */
        std::vector< std::vector< Teamcenter::BulkInput* > > &bulkInputsVec /**< (O) The vector of InputsVector for executing postActions */
        );

    /**
        Gets stacked InputsVector objects & OperationDispatchers for postActions for operations if applicable from BullkData, only when current opId and BulkData's opId are same
    */
    int getPostActionsData(
        const std::string &opId,                                            /**< (I) current operation ID */
        std::vector<Teamcenter::OperationDispatcher*> &opDispVec,           /**< (O) The vector of OperationDispatcher for the inputs to execute postActions */
        std::vector< std::vector< Teamcenter::BulkInput* > > &bulkInputsVec /**< (O) The vector of InputsVector for executing postActions */
        );
private:
    /**
        restricting default constructor
    */
    ManageBulkData();

    /**
    Copy constructor and assignment operator declarations as private to restrict
    */
    ManageBulkData( const ManageBulkData &  other );
    ManageBulkData &  operator=( const ManageBulkData &  other );

    /**
        Creates a BulkData object
    */
    int createBulkData(
        const std::string & opId,       /**< (I) The operation ID */
        BulkData*& bd                   /**< (OF) Created BulkData instance */
        );

    /**
        Deletes a BulkData object
    */
    void deleteBulkData(
        BulkData *obj       /**< (I) Input BulkData instance to be deleted */
        );

    BulkData *m_bd;         /**< Representing BulkData instance */
};

#include <metaframework/libmetaframework_undef.h>
#endif
