/**
 * Special function used by datalint. Checks for duplicate values in base and derived templates.
 */
void ServerManufactureSchematicObjectTemplate::testValues(void) const
{
	IGNORE_RETURN(getDraftSchematic(true));
	IGNORE_RETURN(getCreator(true));
	IGNORE_RETURN(getItemCountMin(true));
	IGNORE_RETURN(getItemCountMax(true));
	ServerIntangibleObjectTemplate::testValues();
}	// ServerManufactureSchematicObjectTemplate::testValues
Example #2
0
BaseDataWidget* DataWidgetFactory::create(QWidget* parent, void* pValue, int fullType,
										  QString widget, QString displayName, QString parameters) const
{
	const BaseDataWidgetCreator* creator = getCreator(fullType, widget);
	if(creator)
		return creator->create(parent, pValue, widget, displayName, parameters);
	return nullptr;
}
Example #3
0
BaseDataWidget* DataWidgetFactory::create(QWidget* parent, panda::BaseData* data) const
{
	const int fullType = data->getDataTrait()->fullTypeId();
	const QString widgetName = QString::fromStdString(data->getWidget());

	const BaseDataWidgetCreator* creator = getCreator(fullType, widgetName);
	if(creator)
		return creator->create(parent, data);
	return nullptr;
}
string Item::getCreatorAndDivisions() const 
{ 
	char* dChar = new char[10]; 
	string retValue = "";

	_itoa(getContentDivisions(), dChar, 10); 
	retValue += getEntryRow(this->getCreatorType(), getCreator()) + '\n';
	retValue += getEntryRow("# " + this->getDivisionType(), string(dChar));

	delete [] dChar;
	dChar = 0;

	return retValue;
}
int ToolsCollection::add(const string& name, int cost)
{
	// Verificar se e' utilitario
	if (!getCreator().has(name)) return -1;
	// Verificar se ja existe
	int idx = item(name);
	if (idx >= 0)
	{
		// Atualizar o custo
		if (cost > 0)
			listTools[idx].setCost(cost);
		return idx;
	}
	else
	{
		// Valor por defeito
		if (cost == 0) cost = 10;
		// Insere na lista
		listTools.push_back(ToolItem(*this,name,cost));
		return listTools.size()-1; //Index
	}
}
TcxActivities * Edge305Device::printActivities(garmin_list * runList, garmin_list * lap, garmin_list * track, const garmin_unit garmin) {

    TcxActivities * activities = new TcxActivities();

    garmin_list_node * runNode = runList->head;

    while (runNode != NULL) {
        garmin_data *run = runNode->data;
        if ((run != NULL) && (run->data != NULL)) {

            uint32 track_index;
            uint32 first_lap_index;
            uint32 last_lap_index;
            uint8  sport_type;

            if ( _get_run_track_lap_info(run,&track_index,&first_lap_index,&last_lap_index,&sport_type) != 0 ) {

                if (Log::enabledDbg()) {
                    stringstream ss;
                    ss << "This run goes from lap id " << first_lap_index << " to " << last_lap_index << " with track id: " << track_index;
                    Log::dbg(ss.str());
                }

                TcxActivity * singleActivity = new TcxActivity("");
                *activities << singleActivity;
                *singleActivity << getCreator(garmin);

                switch (sport_type) {
                    case D1000_running:
                        this->runType = 1;
                        singleActivity->setSportType(TrainingCenterDatabase::Running);
                        break;
                    case D1000_biking:
                        singleActivity->setSportType(TrainingCenterDatabase::Biking);
                        this->runType = 0;
                        break;
                    default:
                        singleActivity->setSportType(TrainingCenterDatabase::Other);
                        this->runType = 2;
                        break;
                }

                bool firstLap = true;
                for ( garmin_list_node * n = lap->head; n != NULL; n = n->next ) {
                    D1011 * lapData = NULL;
                    D1001 * lapData301 = NULL;
                    if (n->data->type == data_D1011) { // Edge 305 uses this
                        lapData = (D1011*)n->data->data;
                    } else if (n->data->type == data_D1015) { // Forerunner 205 uses this
                        lapData = (D1011*)n->data->data; // cast to wrong type - is safe because D1015 is identical, just a little bit longer
                    } else if (n->data->type == data_D1001) { // Forerunner 301 uses this
                        lapData301 = (D1001*)n->data->data;
                    } else {
                        stringstream ss;
                        ss << "Unknown lap type is: " << n->data->type;
                        Log::dbg(ss.str());
                    }

                    if ((lapData != NULL) || (lapData301 != NULL)) {
                        uint32 current_lap_index = 0;
                        time_type current_start_time = 0;
                        if (lapData != NULL) {
                            current_lap_index = lapData->index;
                            current_start_time = lapData->start_time;
                        }
                        if (lapData301 != NULL) {
                            current_lap_index = lapData301->index;
                            current_start_time = lapData301->start_time;
                        }

                        if ((current_lap_index >= first_lap_index) && (current_lap_index <= last_lap_index)) {

                            uint32 startTimeNextLap = getNextLapStartTime(n);

                            TcxLap * singleLap = NULL;
                            if (lapData != NULL) {
                                singleLap = getLapHeader(lapData);
                            } else {
                                singleLap = getLapHeader(lapData301);
                            }
                            int pointCount = 0;
                            if (Log::enabledDbg()) {
                                stringstream ss;
                                ss << "Creating new lap: " << current_lap_index ;
                                Log::dbg(ss.str());
                            }
                            *singleActivity<< singleLap;
                            if (firstLap) {
                                singleActivity->setId(GpsFunctions::print_dtime(current_start_time));
                                firstLap = false;
                            }

                            uint32 currentTrackIndex = 0;
                            TcxTrack * singleTrack = NULL;
                            for ( garmin_list_node * t = track->head; t != NULL; t = t->next ) {
                                if (t->data->type == data_D311) {
                                    D311 * d311 = (D311 *)t->data->data;
                                    currentTrackIndex = d311->index;
                                    if (d311->index == track_index) {
                                        singleTrack = new TcxTrack();
                                        *singleLap << singleTrack;
                                    }
                                } else if (t->data->type == data_D304) {
                                    D304 * trackpointData = (D304 *)t->data->data;
                                    if (currentTrackIndex == track_index) {
                                        if (singleTrack != NULL) {
                                            if (trackpointData->time >= current_start_time) {
                                                if (startTimeNextLap > 0) {
                                                    if (trackpointData->time < startTimeNextLap) {
                                                        (*singleTrack) << getTrackPoint(trackpointData);
                                                        pointCount++;
                                                    }
                                                } else {
                                                    (*singleTrack) << getTrackPoint(trackpointData);
                                                    pointCount++;
                                                }
                                            }

                                        } else {
                                            Log::err("Current track is null - but track index matches !?");
                                        }
                                    }
                                } else  if (t->data->type == data_D303) { // Used by forerunner301
                                    D303 * trackpointData = (D303 *)t->data->data;
                                    if (currentTrackIndex == track_index) {
                                        if (singleTrack != NULL) {
                                            if (trackpointData->time >= current_start_time) {
                                                if (startTimeNextLap > 0) {
                                                    if (trackpointData->time < startTimeNextLap) {
                                                        (*singleTrack) << getTrackPoint(trackpointData);
                                                        pointCount++;
                                                    }
                                                } else {
                                                    (*singleTrack) << getTrackPoint(trackpointData);
                                                    pointCount++;
                                                }
                                            }

                                        } else {
                                            Log::err("Current track is null - but track index matches !?");
                                        }
                                    }

                                } else {
                                    stringstream ss;
                                    ss << "Unknown track point: " << t->data->type;
                                    Log::dbg(ss.str());
                                }
                            }
                            if (Log::enabledDbg()) {
                                stringstream ss;
                                ss << "Point count for this lap: " << pointCount;
                                Log::dbg(ss.str());
                            }
                        }

                    } else {
                        Log::dbg("Unknown Lap Type found in data");
                    }
                }
                if (Log::enabledDbg()) {
                    Log::dbg("Added Lap: " + singleActivity->getOverview());
                }
            }
        } else {
            Log::dbg("Not a run :-(");
        }
        runNode = runNode->next;
    }

    return activities;
}
void* ToolsCollection::create(const string& name)
{
	return getCreator().create(name);
}