/** * Cast the element to a container. * * @param element The element to cast. * @param success Is the cast successful? */ Container CastToContainer(Element const& element, bool& success) { std::shared_ptr<Element_> element_ = element.ElementHandle(); std::shared_ptr<Container_> container = std::dynamic_pointer_cast<Container_>(element_); success = (0 != container.get()); return success ? Container(container, element.GetSourceLocation()) : Container(); }
void MeeleEnemy::ProccessAI() { Character* player = GameObjectHolder::instance().GetPlayer(); int difx = abs( player->Container()->x - Container()->x ); int dify = abs( player->Container()->y - Container()->y ); int distnace = ( int ) sqrt( difx + dify + 0.0 ); distnace = abs( distnace ); if( distnace > 10 ) { ArtificialIntelligence::ProccessAI(); } else { int todo = rand() % 50 + 1; if( todo == 1 ) { Attack* activeAttack = GetActiveAttack(); CombatSystem::instance().ProcessAttackOnPlayer( activeAttack ); } else { ArtificialIntelligence::ProccessAI(); } } }
void NumberEntry::SetRangeValueAt(int index, int length, int value) { for (index += length - 1; length != 0; length--, index--, value /= 10) m_items[index].value = value % 10; if (Container() != NULL) Container()->Refresh(this); }
static object get_slice(Container& container, index_type from, index_type to) { if (from > to) return object(Container()); return object(Container(container.begin()+from, container.begin()+to)); }
// --------------------------------------------------------------------------- // CGSSenTappingCtrlView::HandleCommandL() // Command handling for sensor activation status view // --------------------------------------------------------------------------- void CGSSenTappingCtrlView::HandleCommandL( TInt aCommand ) { TRACE_1( "[GSSensorPlugin] CGSSenTappingCtrlView::HandleCommandL() - command: %i", aCommand ); switch ( aCommand ) { case EGSSenMskGeneral: { // Update checkbox and selections HandleListBoxSelectionL(); // Update MSK label CheckMiddleSoftkeyLabelL(); break; } case EGSCmdOk: // Check selections Container()->CheckSelections(); // Store changes and show previous view Container()->StoreSelectionsL(); // cont. to next case case EAknSoftkeyBack: { // activate previous view iAppUi->ActivateLocalViewL( KGSSensorPluginUid ); break; } default: iAppUi->HandleCommandL( aCommand ); break; } TRACE_( "[GSSensorPlugin] CGSSenTappingCtrlView::HandleCommandL() - return" ); }
/** * Cast the element to a container. * * @param element The element to cast. * @param success Is the cast successful? */ Container CastToContainer(Element const& element, bool& success) { Element_* element_ = const_cast<Element_*>(element.ElementHandle()); Container_* container = dynamic_cast<Container_*>(element_); success = (0 != container); return success ? Container(container, element.GetSourceLocation()) : Container(); }
TEST(RTTITests, BasicTypes) { const std::string name = "Test"; std::vector<Container> test_vector; int i = 0; test_vector.push_back(Container((int)10)); EXPECT_EQ(reflection::GetTypeID<int>(), test_vector[i].GetType()); EXPECT_NE(reflection::GetTypeID<test_datatype>(), test_vector[i].GetType()); EXPECT_EQ(sizeof(int), test_vector[i].GetSize()); EXPECT_TRUE(test_vector[i].Is<int>()); EXPECT_FALSE(test_vector[i].Is<int64_t>()); EXPECT_FALSE(test_vector[i].Is<unsigned int>()); EXPECT_FALSE(test_vector[i].Is<test_datatype>()); test_vector.push_back(Container((int64_t)10)); i++; EXPECT_EQ(reflection::GetTypeID<int64_t>(), test_vector[i].GetType()); EXPECT_NE(reflection::GetTypeID<test_datatype>(), test_vector[i].GetType()); EXPECT_EQ(sizeof(int64_t), test_vector[i].GetSize()); EXPECT_TRUE(test_vector[i].Is<int64_t>()); EXPECT_FALSE(test_vector[i].Is<int>()); EXPECT_FALSE(test_vector[i].Is<unsigned long>()); EXPECT_FALSE(test_vector[i].Is<test_datatype>()); test_vector.push_back(Container(std::string("test"))); i++; EXPECT_EQ(reflection::GetTypeID<std::string>(), test_vector[i].GetType()); EXPECT_NE(reflection::GetTypeID<test_datatype>(), test_vector[i].GetType()); EXPECT_TRUE(test_vector[i].Is<std::string>()); EXPECT_FALSE(test_vector[i].Is<long>()); EXPECT_FALSE(test_vector[i].Is<double>()); EXPECT_FALSE(test_vector[i].Is<test_datatype>()); }
static object get_slice(Container& container, index_type from, index_type to) { if (from > to) return object(Container()); return object(Container(boost::next(container.begin(),from), boost::next(container.begin(), to))); }
// --------------------------------------------------------------------------- // CGSSenTappingCtrlView::HandleListBoxSelectionL // --------------------------------------------------------------------------- void CGSSenTappingCtrlView::HandleListBoxSelectionL() { TRACE_( "[GSSensorPlugin] CGSSenTappingCtrlView::HandleListBoxSelectionL()" ); const TInt currentItem = Container()->CurrentFeatureId(); Container()->ChangeSelectionStatus( currentItem ); Container()->UpdateCheckboxIconL( currentItem ); TRACE_( "[GSSensorPlugin] CGSSenTappingCtrlView::HandleListBoxSelectionL() - return" ); }
Container find_inversions_by_mergesort(Container const& seq, typename Container::size_type & count) { if (seq.size() > 1) { auto mid = seq.cbegin() + seq.size() / 2; auto lhs = find_inversions_by_mergesort(Container(seq.cbegin(), mid), count); auto rhs = find_inversions_by_mergesort(Container(mid, seq.cend()), count); return merge_and_count_invertions(lhs, rhs, count); } return seq; }
void WrapperView::AddedToContainer() { _UpdateViewFrame(); Container()->AddChild(fView); }
// ---------------------------------------------------------------------------- // try to test create a volume control from IDLE state. // ---------------------------------------------------------------------------- // void CTestVolumeNaviPane::TestIdleL() { CEikonEnv::Static()->AppUiFactory()->StatusPane()->SwitchLayoutL( R_AVKON_STATUS_PANE_LAYOUT_IDLE ); #ifdef R_AVKON_STATUS_PANE_LAYOUT_IDLE_EXT { CEikonEnv::Static()->AppUiFactory()->StatusPane()->SwitchLayoutL( R_AVKON_STATUS_PANE_LAYOUT_IDLE_EXT ); } #endif CEikonEnv::Static()->AppUiFactory()->StatusPane()->CurrentLayoutResId(); AssertTrueL( ETrue, _L("Set Navi pane to IDLE") ); TryCreateL(R_AVKON_NAVI_PANE_VOLUME_INDICATOR, R_BCTESTVOLUME_TEXT_LABEL_OPERATION); TryAdjustL(); Container()->UpdateComponentsL(); CEikonEnv::Static()->AppUiFactory()->StatusPane()->SwitchLayoutL( R_AVKON_STATUS_PANE_LAYOUT_USUAL ); #ifdef R_AVKON_STATUS_PANE_LAYOUT_USUAL_EXT { CEikonEnv::Static()->AppUiFactory()->StatusPane()->SwitchLayoutL( R_AVKON_STATUS_PANE_LAYOUT_USUAL_EXT ); } #endif AssertTrueL( ETrue, _L("Set Navi pane to Usual") ); }
ValueNode::Container& ValueNode::CheckNodes() const { if(!Value) Value = Container(); return GetContainer(); }
Item* Item::Create(uint16_t _type, uint16_t _subtype /*= 0xFFFF*/) { if(_type == 0) return nullptr; Item* newItem = nullptr; const ItemType& it = item_db[_type]; if(it.id != 0){ if(it.isDepot()) { newItem = newd Depot(_type); } else if(it.isContainer()) { newItem = newd Container(_type); } else if(it.isTeleport()) { newItem = newd Teleport(_type); } else if(it.isDoor()) { newItem = newd Door(_type); } else if(_subtype == 0xFFFF) { if(it.isFluidContainer()) { newItem = newd Item(_type, LIQUID_NONE); } else if(it.isSplash()) { newItem = newd Item(_type, LIQUID_WATER); } else if(it.charges > 0) { newItem = newd Item(_type, it.charges); } else { newItem = newd Item(_type, 1); } } else { newItem = newd Item(_type, _subtype); } } else { newItem = newd Item(_type, _subtype); } return newItem; }
int main() { use_pair (Container (1234)); if (myArray[0] != 1234) return 1; }
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::is_sub_array<Container>::value, Container>::type sub_window( Container const& arr, typename sprout::container_traits<Container>::difference_type to_first = 0 ) { return Container(arr, to_first, sprout::size(arr)); }
bool compare_encoded (char const * src, char const * result) { pfs::byte_string in(src); Container out; pfs::base64_encode(in, out); return out == Container(result); }
Element InterpretContainer_(Container container) { Element out = Container(); if (container.NumberOfElements() > 1) { out = container.Cdr(); } return out; }
Container stable_sort_uniq_build(R arg_range ///< The range on which the stable_sorted, uniqued copy should be based ) { return stable_sort_uniq_copy( Container( common::cbegin( arg_range ), common::cend ( arg_range ) ) ); }
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::is_sub_array<Container>::value, Container>::type sub_offset( Container const& arr, typename sprout::container_traits<Container>::difference_type from_begin = 0, typename sprout::container_traits<Container>::difference_type from_end = 0 ) { return Container(arr, from_begin, sprout::size(arr) + from_end); }
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::is_sub_array<Container>::value, Container>::type sub( Container const& arr, typename sprout::container_traits<Container>::const_iterator first, typename sprout::container_traits<Container>::const_iterator last ) { return Container(arr, first, last); }
Container uniq_build(R arg_range ///< The range on which the uniqued copy should be based ) { return uniq_copy( Container( common::cbegin( arg_range ), common::cend ( arg_range ) ) ); }
// ---------------------------------------------------------------------------- // try to test creation of the volume control inside navigation pane. // ---------------------------------------------------------------------------- // void CTestVolumeNaviPane::TryCreateL(TInt aResourceID, TInt aLabelID) { // Creates Navi pane volume glider object. CAknNavigationDecorator* decorator = Container()->NaviPane()->CreateVolumeIndicatorL( aResourceID ); AssertNotNullL(decorator, _L("Volume indicator created by NaviPane:")); Container()->NaviPane()->PushL( *decorator ); CAknVolumeControl* volume = static_cast<CAknVolumeControl*>(decorator->DecoratedControl() ); AssertNotNullL(volume, _L("Get decorate control:")); // Adds volume control to control stack. // Volume control can get offered key event. CEikonEnv::Static()->EikAppUi()->AddToStackL( volume ); Container()->SetDecorator(decorator); //to be removed later Container()->CreateLabelL( aLabelID ); iVolume=volume; }
//------------------------------------------------------------------------------ // FunctionGroupWidget // FunctionGroupWidget::FunctionGroupWidget(int index, const QString& title, const QStringList& groupShortNames, QWidget* parent) : HeaderContainerWidget(index, title, parent) { FunctionBlockListView* view = new FunctionBlockListView(this); view->setModel(&m_model); view->setEditTriggers(QAbstractItemView::NoEditTriggers); Container()->layout()->addWidget(view); Header()->SetColor(QColor(168,60,15)); Init(groupShortNames); }
inline static Container make(std::size_t size) { if(v.size() != size) { v.clear(); v.resize(size); for(std::size_t i = 0; i < size; ++i) { v.push_back({i}); } } return Container(); }
Container stable_sort_build(R arg_range, ///< The range on which the sorted copy should be based P arg_bin_pred ///< The binary predicate to use as a less-than operator for sorting ) { return stable_sort_copy( Container( common::cbegin( arg_range ), common::cend ( arg_range ) ), arg_bin_pred ); }
// This method will do the main data processing job. ModuleState::MODULE_EXITCODE Proxy::body() { uint32_t captureCounter = 0; while (getModuleState() == ModuleState::RUNNING) { // Capture frame. if (m_camera != NULL) { core::data::image::SharedImage si = m_camera->capture(); Container c(Container::SHARED_IMAGE, si); distribute(c); captureCounter++; } Container containerVehicleControl = getKeyValueDataStore().get(Container::VEHICLECONTROL); VehicleControl vc = containerVehicleControl.getData<VehicleControl>(); cerr << "Speed: '" << vc.getSpeed() << "'" << endl; cerr << "Angle: '" << vc.getSteeringWheelAngle() << "'" << endl; // TODO: Here, you need to implement the data links to the embedded system // to read data from IR/US. // Test *************************** // Markus Erlach string in = ""; string rec; char command[10]; cout << "Enter command to send, " << endl; cout << "Command alternatives: w, f, s, r, n, h, v, m" << endl; cin >> in; /* w, f, s, r, n, h, v w = set speed to 1560, f = accelerate by 10 s = slow down, r = reverse, n = neutral h = turn right, v = turn left */ strcpy(command, in.c_str()); write(port, command, 10); cout << "Proxy2 wrote: "<< command << endl; rec = msv::readSerial(); decode(rec); Container c = Container(Container::USER_DATA_0, sensorBoardData); distribute(c); /*int IR1Data = sensorBoardData.getValueForKey_MapOfDistances(0); cout << "SBD IR1: " << IR1Data << endl; */ //flushes the input queue, which contains data that have been received but not yet read. tcflush(port, TCIFLUSH); } cout << "Proxy: Captured " << captureCounter << " frames." << endl; return ModuleState::OKAY; }
// --------------------------------------------------------------------------- // CGSSenTappingCtrlView::CheckMiddleSoftkeyLabelL // --------------------------------------------------------------------------- // void CGSSenTappingCtrlView::CheckMiddleSoftkeyLabelL() { TRACE_( "[GSSensorPlugin] CGSSenTappingCtrlView::CheckMiddleSoftkeyLabelL()" ); // First, resolve current item const TInt currentItem = Container()->CurrentFeatureId(); // Remove current label RemoveCommandFromMSK(); // Resolve is currently selected item checked or unchecked and change MSK label accordingly if ( Container()->SelectionStatus( currentItem ) ) { // Change MKS to 'Unmark' SetMiddleSoftKeyLabelL( R_GS_MKS_LABEL_UNMARK, EGSSenMskGeneral ); } else { // Change MSK to 'Mark' SetMiddleSoftKeyLabelL( R_GS_MKS_LABEL_MARK, EGSSenMskGeneral ); } TRACE_( "[GSSensorPlugin] CGSSenTappingCtrlView::CheckMiddleSoftkeyLabelL() - return" ); }
void NumberEntry::OnPress(BUTTON_TYPE button) { switch (button) { default: Control::OnPress(button); break; case btRightTop: m_items[m_index].value++; if (m_items[m_index].value > m_items[m_index].max) m_items[m_index].value = m_items[m_index].min; Container()->Refresh(this); Fire((void*)m_index); break; case btRightCentre: { int find = m_index; do { find++; if (find >= m_count) find = 0; if (find == m_index) // Sanity check break; } while (m_items[find].type != tDigit); m_index = find; Container()->Refresh(this); } break; case btRightBottom: m_items[m_index].value--; if (m_items[m_index].value < m_items[m_index].min) m_items[m_index].value = m_items[m_index].max; Container()->Refresh(this); Fire((void*)m_index); break; } }
bool Container::equalTree(Object const* o1, Object const * o2) { Q_ASSERT(o1 && o2); if(o1==o2) return true; bool eq= o1->type()==o2->type(); switch(o2->type()) { case Object::variable: eq = eq && Ci(o2)==Ci(o1); break; case Object::value: eq = eq && Cn(o2)==Cn(o1); break; case Object::container: eq = eq && Container(o2)==Container(o1); break; case Object::oper: eq = eq && Operator(o2)==Operator(o1); break; default: break; } return eq; }