/*
 * Copyright (C) 2015, Samsung Electronics Co. LTD
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef EXYNOS_VISION_TARGET_H
#define EXYNOS_VISION_TARGET_H

#include <map>

#include <VX/vx.h>
#include <VX/vx_internal.h>

#include "ExynosVisionReference.h"
#include "ExynosVisionKernel.h"

namespace android {
using namespace std;

class ExynosVisionTarget : public ExynosVisionReference {
private:
    vx_char m_target_name[VX_MAX_TARGET_NAME];
    vx_enum m_target_enum;
    map<vx_enum, ExynosVisionKernel*>    m_kernel_map;

public:

private:

public:
    /* Constructor */
    ExynosVisionTarget(ExynosVisionContext *context, const vx_char name[VX_MAX_TARGET_NAME]);

    /* Destructor */
    virtual ~ExynosVisionTarget(void);

    virtual vx_status destroy(void);

    vx_char *getTargetName(void)
    {
        return m_target_name;
    }

    vx_enum getTargetEnum(void)
    {
        return m_target_enum;
    }

    vx_uint32 getKernelsNum()
    {
        return m_kernel_map.size();
    }

    ExynosVisionKernel* addKernel(const vx_char name[VX_MAX_KERNEL_NAME],
                                                     vx_enum enumeration,
                                                     vx_kernel_f func_ptr,
                                                     vx_uint32 numParams,
                                                     vx_kernel_input_validate_f input,
                                                     vx_kernel_output_validate_f output,
                                                     vx_kernel_initialize_f init,
                                                     vx_kernel_deinitialize_f deinit);
    ExynosVisionKernel* getKernelByEnum(vx_enum kernel_enum);
    ExynosVisionKernel* getKernelByName(const vx_char *name);
    ExynosVisionKernel* getKernelByIndex(vx_uint32 index);
    vx_status removeKernel(ExynosVisionKernel **kernel);

    virtual void displayInfo(vx_uint32 tab_num, vx_bool detail_info);

    static vx_enum getTargetEnumByName(const vx_char *name);
    static vx_char* getTargetNameByEnum(vx_enum target_enum);
    static vx_enum getTargetEnumByTargetString(const vx_char *target_string);
};

}; // namespace android
#endif
