当前位置: 首页>>代码示例>>C++>>正文


C++ Duration函数代码示例

本文整理汇总了C++中Duration函数的典型用法代码示例。如果您正苦于以下问题:C++ Duration函数的具体用法?C++ Duration怎么用?C++ Duration使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Duration函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: UTIL_ScreenFade

//-----------------------------------------------------------------------------
// Purpose: Input handler that does the screen fade.
//-----------------------------------------------------------------------------
void CEnvFade::InputFade( inputdata_t &inputdata )
{
	int fadeFlags = 0;

	if ( m_spawnflags & SF_FADE_IN )
	{
		fadeFlags |= FFADE_IN;
	}
	else
	{
		fadeFlags |= FFADE_OUT;
	}

	if ( m_spawnflags & SF_FADE_MODULATE )
	{
		fadeFlags |= FFADE_MODULATE;
	}

	if ( m_spawnflags & SF_FADE_STAYOUT )
	{
		fadeFlags |= FFADE_STAYOUT;
	}

	if ( m_spawnflags & SF_FADE_ONLYONE )
	{
		if ( inputdata.pActivator->IsNetClient() )
		{
			UTIL_ScreenFade( inputdata.pActivator, m_clrRender, Duration(), HoldTime(), fadeFlags );
		}
	}
	else
	{
		UTIL_ScreenFadeAll( m_clrRender, Duration(), HoldTime(), fadeFlags|FFADE_PURGE );
	}

	m_OnBeginFade.FireOutput( inputdata.pActivator, this );
}
开发者ID:AluminumKen,项目名称:hl2sb-src,代码行数:40,代码来源:envfade.cpp

示例2: ROS_INFO

bool ObjectManipulation::placeObject(string arm_name, double x_offset, double y_offset, double z_offset, double max_seconds_wait_for_conclusion) {
	if (processing_srv_.response.graspable_objects.empty() || processing_srv_.response.collision_object_names.empty()) {
		return false;
	}

	geometry_msgs::PoseStamped place_location;
	place_location.header.frame_id = processing_srv_.response.graspable_objects.at(0).reference_frame_id;
	place_location.pose.orientation.w = 1;
	place_location.header.stamp = ros::Time::now();
	place_location.pose.position.x += x_offset;
	place_location.pose.position.y += y_offset;

	direction_.header.stamp = ros::Time::now();
	direction_.header.frame_id = "base_link";
	direction_.vector.x = 0;
	direction_.vector.y = 0;
	direction_.vector.z = -1;

	ROS_INFO("Calling the place action");
	object_manipulation_msgs::PlaceGoal place_goal;
	place_goal.place_locations.push_back(place_location);
	place_goal.collision_object_name = processing_srv_.response.collision_object_names.at(0);
	place_goal.collision_support_surface_name = processing_srv_.response.collision_support_surface_name;
	place_goal.grasp = pickup_result_.grasp;
	place_goal.arm_name = arm_name;
	place_goal.place_padding = 0.02;
	place_goal.desired_retreat_distance = 0.1;
	place_goal.min_retreat_distance = 0.05;
	place_goal.approach.direction = direction_;
	place_goal.approach.desired_distance = z_offset;
	place_goal.approach.min_distance = 0.05;
	place_goal.use_reactive_place = false;


	place_client_.sendGoal(place_goal);
	ROS_INFO("Waiting for the place action...");
	if (!place_client_.waitForResult(Duration(max_seconds_wait_for_conclusion))) {
		return false;
	}

	object_manipulation_msgs::PlaceResult place_result = *(place_client_.getResult());
	if (place_client_.getState() != actionlib::SimpleClientGoalState::SUCCEEDED) {
		ROS_ERROR("Place failed with error code %d", place_result.manipulation_result.value);
		return false;
	}

	ROS_INFO("Object moved");
	return true;
}
开发者ID:carlosmccosta,项目名称:Robot-Object-Manipulation,代码行数:49,代码来源:ObjectManipulation.cpp

示例3: Duration

////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value.
void ColumnRecur::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{
  if (_style == "default" ||
      _style == "duration")
  {
    minimum = maximum = Duration (task.get ("recur")).formatCompact ().length ();
  }
  else if (_style == "indicator")
  {
    if (task.has (_name))
      minimum = maximum = context.config.get ("recurrence.indicator").length ();
  }
  else
    throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
}
开发者ID:nigeil,项目名称:task,代码行数:17,代码来源:ColRecur.cpp

示例4: date

////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value.
void ColumnDue::measure (Task& task, int& minimum, int& maximum)
{
  minimum = maximum = 0;

  if (task.has (_name))
  {
    if (_style == "countdown")
    {
      Date date ((time_t) strtol (task.get (_name).c_str (), NULL, 10));
      Date now;
      minimum = maximum = Duration (now - date).format ().length ();
    }
    else
      ColumnDate::measure (task, minimum, maximum);
  }
}
开发者ID:SEJeff,项目名称:task,代码行数:18,代码来源:ColDue.cpp

示例5: TimeToPixels

void TExportZone::TrackOutMarker(BPoint mousePt)
{					
	//	Constrain to out time of cue sheet
	uint32 outPixels = TimeToPixels( Duration() - StartTime(), GetCurrentTimeFormat(), GetCurrentResolution());
	
	if (mousePt.x > outPixels)
		mousePt.x = outPixels;

	//	Don't allow overlap with m_InRect
	if ( (mousePt.x-kExportSliderWidth) < m_InRect.right)
		mousePt.x = m_InRect.right + kExportSliderWidth;

	// Save oldRect for redraw														
	BRect oldRect 	= m_OutRect;	
	m_OutRect.right = mousePt.x;	
	m_OutRect.left = m_OutRect.right - kExportSliderWidth;	
	
	
	// Exit if there is no change in position
	if (oldRect == m_OutRect)
		return;

	//	Update m_ExportChannel
	m_ExportChannel.right = m_OutRect.left;
	
	//	Clean up old position
	BRect updateRect = oldRect;
	
	if (m_OutRect.left <= oldRect.left)
	{
		updateRect.left = m_OutRect.left;		
	}
	else
	{
		updateRect.right  = m_OutRect.right;
	}
	
	Draw(updateRect);
	
	//	Update CueSheet variable
	uint32 newOutTime = StartTime() + PixelsToTime(m_OutRect.right, GetCurrentTimeFormat(), GetCurrentResolution());
	m_CueSheetWindow->GetCueSheetView()->SetExportStopTime(newOutTime);

	//	Update text
	m_CueSheetWindow->GetExportTimeView()->DrawOutText();
	
}
开发者ID:ModeenF,项目名称:UltraDV,代码行数:47,代码来源:TExportZone.cpp

示例6: segment_time_elapsed

MoveSpline::UpdateResult MoveSpline::_updateState(int32& ms_time_diff)
{
	if (ms_time_diff < 0)
	{
		ms_time_diff = 0;
		return Result_Arrived;
	}

    if (Finalized())
    {
        ms_time_diff = 0;
        return Result_Arrived;
    }

    UpdateResult result = Result_None;

    int32 minimal_diff = std::min(ms_time_diff, segment_time_elapsed());
    ASSERT(minimal_diff >= 0);
    time_passed += minimal_diff;
    ms_time_diff -= minimal_diff;

    if (time_passed >= next_timestamp())
    {
        ++point_Idx;
        if (point_Idx < spline.last())
        {
            result = Result_NextSegment;
        }
        else
        {
            if (spline.isCyclic())
            {
                point_Idx = spline.first();
                time_passed = time_passed % Duration();
                result = Result_NextSegment;
            }
            else
            {
                _Finalize();
                ms_time_diff = 0;
                result = Result_Arrived;
            }
        }
    }

    return result;
}
开发者ID:Expecto,项目名称:FCore,代码行数:47,代码来源:MoveSpline.cpp

示例7: Duration

Duration
Time::operator-(const rclcpp::Time & rhs) const
{
  if (rcl_time_.clock_type != rhs.rcl_time_.clock_type) {
    throw std::runtime_error("can't subtract times with different time sources");
  }

  if (rclcpp::sub_will_overflow(rcl_time_.nanoseconds, rhs.rcl_time_.nanoseconds)) {
    throw std::overflow_error("time subtraction leads to int64_t overflow");
  }

  if (rclcpp::sub_will_underflow(rcl_time_.nanoseconds, rhs.rcl_time_.nanoseconds)) {
    throw std::underflow_error("time subtraction leads to int64_t underflow");
  }

  return Duration(rcl_time_.nanoseconds - rhs.rcl_time_.nanoseconds);
}
开发者ID:jwang11,项目名称:rclcpp,代码行数:17,代码来源:time.cpp

示例8: assert

//--------------------------------------------------------------------------------------
// Name: GetPacketCumulativeBytesSize()
// Desc: Gets the packet count and the total byte size of the 'dpds' chunk.
//--------------------------------------------------------------------------------------
HRESULT WaveFile::GetPacketCumulativeBytesSize(DWORD* pdwPacketCount, DWORD* pdwBufferSize)
{
    assert( m_DpdsChunk.IsValid() );

    if (!m_DpdsChunk.IsValid())
        return E_HANDLE;

    WAVEFORMATEXTENSIBLE wfxFormat;
    GetFormat( &wfxFormat );
    
    // Packet count: length of the 'data' chunk divided by number of bytes per packet
    *pdwPacketCount = Duration() / wfxFormat.Format.nBlockAlign;

    *pdwBufferSize = m_DpdsChunk.GetDataSize();

    return S_OK;
}
开发者ID:AlexSincennes,项目名称:CSCI522A6,代码行数:21,代码来源:AtgAudio.cpp

示例9: DoGameMove

void DoGameMove(GAME *Game, int Move, double Value, double Time) {

   if (! IsLegalMove(Game->Board,Move)) FatalError("Illegal move in DoGameMove()");

   TurnTime = (Trust && Time >= 0.0) ? Time : Duration(TurnBegin,CurrentTime());
   ElapsedTime[Game->Board->Colour>0] += TurnTime;

   DoMove(Game->Board,Move);

   Game->Move[Game->MoveNo].Move  = Move;
   Game->Move[Game->MoveNo].Value = Value;
   Game->Move[Game->MoveNo].Time  = TurnTime;
   Game->MoveNo++;
   Game->Move[Game->MoveNo].Move  = NO_MOVE;

   TurnBegin = CurrentTime();
}
开发者ID:zhu-jz,项目名称:turtle,代码行数:17,代码来源:game.c

示例10: Draw

//-----------------------------------------------------------------------
void DebugNavigator::Draw(DrawingContext & drawingContext)
{
    constexpr float minFramerate = 10.0f;
    constexpr float maxFramerate = 60.0f;
    constexpr std::uint16_t maxHistories = 20;

    {
        if (clock->TotalGameTime() - duration > Duration(0.2))
        {
            auto frameRate = clock->FrameRate();
            frameRateString = StringFormat("%4.2f fps", frameRate);
            frameRates.push_back(MathHelper::Clamp(frameRate, minFramerate, maxFramerate));

            if (frameRates.size() > maxHistories)
            {
                frameRates.pop_front();
            }
            duration = clock->TotalGameTime();
        }
    }

    auto transform = Transform() * drawingContext.Top();
    {
        auto graphTransform = Matrix3x2::CreateTranslation(Vector2{0, 16}) * transform;

        constexpr std::uint16_t maxGraphHeight = 26;
        constexpr float graphMarginLeft = 1.0f;

        auto graghWidth = (static_cast<float>(Width()) / maxHistories);

        std::int32_t startPosition = graghWidth * (maxHistories - frameRates.size());
        std::int32_t graphX = startPosition;
        for (auto & frameRate: frameRates)
        {
            auto amount = ((frameRate - minFramerate) / (maxFramerate - minFramerate));
            auto graphHeight = MathHelper::Clamp<std::uint16_t>(maxGraphHeight * amount, 1, maxGraphHeight);

            drawingContext.DrawRectangle(graphTransform, Color::CornflowerBlue,
                Rectangle(graphX, maxGraphHeight - graphHeight, graghWidth - graphMarginLeft, graphHeight));
            graphX += graghWidth;
        }
    }

    drawingContext.DrawString(transform * Matrix3x2::CreateTranslation({0.5f, -2.5f}),
        Color::White, FontWeight::Bold, FontSize::Medium, frameRateString);
}
开发者ID:Mourtz,项目名称:pomdog,代码行数:47,代码来源:DebugNavigator.cpp

示例11: get_state

 void
 IBeamTool::set_leading_x (const int x)
 {
   shared_ptr<TimelineState> state = get_state();
   
   // The line below needs handled differently now;  ////////////TODO GTK-3
   //
   //const bool set_playback_period = dragType == Selection;
   
   TimeVar newStartPoint (state->getViewWindow().x_to_time(x));
   Offset selectionLength (pinnedDragTime, newStartPoint);
   
   if (newStartPoint > pinnedDragTime)
     newStartPoint=pinnedDragTime; // use the smaller one as selection start
   
   selectionControl (TimeSpan (newStartPoint, Duration(selectionLength)));
 }
开发者ID:Ichthyostega,项目名称:Lumiera,代码行数:17,代码来源:timeline-ibeam-tool.cpp

示例12: AverageFrameLength

int64_t
MP3Demuxer::Duration() const {
  if (!mNumParsedFrames) {
    return -1;
  }

  // Assume we know the exact number of frames from the VBR header.
  int64_t numFrames = mParser.VBRInfo().NumFrames();
  if (numFrames < 0) {
    if (mStreamLength < 0) {
      // Unknown length, we can't estimate duration.
      return -1;
    }
    numFrames = (mStreamLength - mFirstFrameOffset) / AverageFrameLength();
  }
  return Duration(numFrames);
}
开发者ID:AtulKumar2,项目名称:gecko-dev,代码行数:17,代码来源:MP3TrackDemuxer.cpp

示例13: parse

  static Try<Duration> parse(const std::string& s)
  {
    // TODO(benh): Support negative durations (i.e., starts with '-').
    size_t index = 0;
    while (index < s.size()) {
      if (isdigit(s[index]) || s[index] == '.') {
        index++;
        continue;
      }

      Try<double> value = numify<double>(s.substr(0, index));

      if (value.isError()) {
        return Error(value.error());
      }

      const std::string unit = s.substr(index);

      if (unit == "ns") {
        return Duration(value.get(), NANOSECONDS);
      } else if (unit == "us") {
        return Duration(value.get(), MICROSECONDS);
      } else if (unit == "ms") {
        return Duration(value.get(), MILLISECONDS);
      } else if (unit == "secs") {
        return Duration(value.get(), SECONDS);
      } else if (unit == "mins") {
        return Duration(value.get(), MINUTES);
      } else if (unit == "hrs") {
        return Duration(value.get(), HOURS);
      } else if (unit == "days") {
        return Duration(value.get(), DAYS);
      } else if (unit == "weeks") {
        return Duration(value.get(), WEEKS);
      } else {
        return Error(
            "Unknown duration unit '" + unit + "'; supported units are"
            " 'ns', 'us', 'ms', 'secs', 'mins', 'hrs', 'days', and 'weeks'");
      }
    }
    return Error("Invalid duration '" + s + "'");
  }
开发者ID:wzqtony,项目名称:mesos,代码行数:42,代码来源:duration.hpp

示例14: switch

Duration Duration::fromString(const QString &s, Format format, bool *ok) {
    if (ok) *ok = false;
    QRegExp matcher;
    Duration tmp;
    switch (format) {
        case Format_Hour: {
            matcher.setPattern("^(\\d*)h(\\d*)m$" );
            int pos = matcher.indexIn(s);
            if (pos > -1) {
                tmp.addHours(matcher.cap(1).toUInt());
                tmp.addMinutes(matcher.cap(2).toUInt());
                if (ok) *ok = true;
            }
            break;
        }
        case Format_DayTime: {
            matcher.setPattern("^(\\d*) (\\d*):(\\d*):(\\d*)\\.(\\d*)$" );
            int pos = matcher.indexIn(s);
            if (pos > -1) {
                tmp.addDays(matcher.cap(1).toUInt());
                tmp.addHours(matcher.cap(2).toUInt());
                tmp.addMinutes(matcher.cap(3).toUInt());
                tmp.addSeconds(matcher.cap(4).toUInt());
                tmp.addMilliseconds(matcher.cap(5).toUInt());
                if (ok) *ok = true;
            }
            break;
        }
        case Format_HourFraction: {
            // should be in double format
            bool res;
            double f = QLocale().toDouble(s, &res);
            if (ok) *ok = res;
            if (res) {
                return Duration((qint64)(f)*3600*1000);
            }
            break;
        }
        default:
            qFatal("Unknown format");
            break;
    }
    return tmp;
}
开发者ID:KDE,项目名称:calligra,代码行数:44,代码来源:kptduration.cpp

示例15: date

////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value.
//
void ColumnUDA::measure (Task& task, int& minimum, int& maximum)
{
  minimum = maximum = 0;

  if (_style == "default")
  {
    std::string value = task.get (_name);
    if (value != "")
    {
      if (_type == "date")
      {
        // Determine the output date format, which uses a hierarchy of definitions.
        //   rc.report.<report>.dateformat
        //   rc.dateformat.report
        //   rc.dateformat.
        Date date ((time_t) strtol (value.c_str (), NULL, 10));
        std::string format = context.config.get ("report." + _report + ".dateformat");
        if (format == "")
          format = context.config.get ("dateformat.report");
        if (format == "")
          format = context.config.get ("dateformat");

        minimum = maximum = date.toString (format).length ();
      }
      else if (_type == "duration")
      {
        minimum = maximum = Duration (value).formatCompact ().length ();
      }
      else if (_type == "string")
      {
        std::string stripped = Color::strip (value);
        maximum = longestLine (stripped);
        minimum = longestWord (stripped);
      }
      else if (_type == "numeric")
      {
        minimum = maximum = value.length ();
      }
    }
  }
  else
    throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
}
开发者ID:codito,项目名称:task,代码行数:46,代码来源:ColUDA.cpp


注:本文中的Duration函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。