TaskGroup.cpp

Go to the documentation of this file.
00001 /*
00002  * This program is free software; you can redistribute it and/or modify
00003  * it under the terms of the GNU General Public License as published by
00004  * the Free Software Foundation; either version 3 of the License, or
00005  * (at your option) any later version.
00006  *
00007  * Copyright (C) 2012 Sergey Lisitsyn
00008  */
00009 
00010 #include <shogun/transfer/multitask/TaskGroup.h>
00011 
00012 using namespace shogun;
00013 
00014 CTaskGroup::CTaskGroup() : CTaskRelation()
00015 {
00016     init();
00017 }
00018 
00019 CTaskGroup::~CTaskGroup()
00020 {
00021     SG_UNREF(m_tasks);
00022 }
00023 
00024 void CTaskGroup::init()
00025 {
00026     m_tasks = new CDynamicObjectArray(true);
00027 }
00028 
00029 void CTaskGroup::append_task(CTask* task)
00030 {
00031     m_tasks->append_element(task);
00032 }
00033 
00034 int32_t CTaskGroup::get_num_tasks() const
00035 {
00036     return m_tasks->get_num_elements();
00037 }
00038 
00039 SGVector<index_t>* CTaskGroup::get_tasks_indices() const
00040 {
00041     int32_t n_tasks = m_tasks->get_num_elements();
00042     SG_DEBUG("Number of tasks = %d\n", n_tasks);
00043     
00044     SGVector<index_t>* tasks_indices = SG_MALLOC(SGVector<index_t>, n_tasks);
00045     for (int32_t i=0; i<n_tasks; i++)
00046     {
00047         new (&tasks_indices[i]) SGVector<index_t>();
00048         CTask* task = (CTask*)m_tasks->get_element(i);
00049         tasks_indices[i] = task->get_indices();
00050         SG_UNREF(task);
00051     }
00052 
00053     return tasks_indices;
00054 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation