Example #1
0
/**
 * Constructor handles program flow. Gets user menu choice then acts on that.
 */
Controller::Controller() {

	bool running = true;
	int menuChoice = -1;

	do {
		menuChoice = view.getMenuChoice();

		if (menuChoice == 1) { // add movies

			DynArray movieList;
			view.getMovies(&movieList);

			localMovies.addAllMovies(&movieList);
			masterMovies.addMovies(&movieList);

		} else if (menuChoice == 2) { // delete movie

			string movieTitle = view.deleteMovie();

			Movie* removedMovie = localMovies.removeMovie(movieTitle);

			for (int i = 0; i < localMovies.getSize(); ++i) {
				if (localMovies.movieList[i]->getTitle().compare(movieTitle)
						== 0) {
					DynArray movieToRemove;
					movieToRemove.addMovie(localMovies.movieList[i]);
					masterMovies.removeMovies(&movieToRemove);
					break;
				}
			}

			delete removedMovie;

		} else if (menuChoice == 3) { // list all movies

			view.listMovies(&localMovies);

		} else if (menuChoice == 4) { // list movies by genre

			Genre genre = view.getGenre();
			DynArray genreMovies;

			for (int i = 0; i < localMovies.getSize(); ++i) {
				if (localMovies.movieList[i]->getGenre() == genre) {
					genreMovies.addMovie(localMovies.movieList[i]);
				}
			}

			view.listMovies(&genreMovies);

		} else if (menuChoice == 0) { // exit
			running = false;

		} else {
			view.displayMessage("Invalid menu option!");
		}
	} while (running);

}
Example #2
0
	void printMap(){
		for(int i = 0; i<keys->getLength();i++){
			cout<< "Key: "<<keys->get(i)<<endl;	
			valarray->get(i)->display();
			cout<<endl;
		}
	}
Example #3
0
int Client::SetExpiry(const ByteString &key, uint64_t expiryTime)
{
	int			status;
	Command*	cmd;
	ByteString	args[2];
	DynArray<32> numString;

	VALIDATE_CLIENT();
	VALIDATE_KEY_LEN(key);
	VALIDATE_SAFE();
	VALIDATE_WRITE();

	numString.Writef("%U", expiryTime);

	args[0] = key;
	args[1] = numString;
	
	cmd = CreateCommand(KEYSPACECLIENT_SET_EXPIRY, SIZE(args), args);
	safeCommands.Append(cmd);
	
	if (IS_BATCHED())
	{
		result->AppendCommand(cmd);
		return KEYSPACE_SUCCESS;
	}
	
	result->Close();
	result->AppendCommand(cmd);

	EventLoop();
	status = result->CommandStatus();
	
	return status;
}
Example #4
0
// FindPaletteIndex()
//  Returns the palette index that most closely matches the given
//  RGB value.  This only works in Indexed mode.  The optional low
//  and high values specify the low and hight palette indices to
//  to search (inclusive).  This is similar to the other
//  FindPaletteIndex() functions, but also takes a pointer to a
//  DynArray of palette indices to match against.
IMG_BYTE ImageClass::FindPaletteIndex( IMG_BYTE r, IMG_BYTE g, IMG_BYTE b, DynArray<int> &array ) {
  if( type != IMAGE_INDEXED )
    return 0;

  if( array.NumElements() == 0 )
    return 0;

  IMG_BYTE  closest    =    0;   // Closest index to the target color
  int       how_close  = 1000;   // 0 == perfect match
  int       this_try;

  int step  = sizeof( IMG_BYTE ) * 3;
  IMG_BYTE * rgb = &(palette[ (array[0]) ]);

  for( unsigned int i=0; i < array.NumElements(); i++ ) {
    rgb = GetPaletteColor( array[i] );

    if( r > rgb[0] )  this_try = r - rgb[0];   // Find the red difference
    else              this_try = rgb[0] - r;

    if( g > rgb[1] )  this_try += g - rgb[1];  // Find the green difference
    else              this_try += rgb[1] - g;

    if( b > rgb[2] )  this_try += b - rgb[2];  // Find the blue difference
    else              this_try += rgb[2] - b;

    if( this_try < how_close ) {               // See if this is closer than the last match
      closest   = array[i];
      how_close = this_try;
    }
  }

  return closest;
}
int main(int argc, char **argv)
{
	init_shogun(&print_message, &print_message, &print_message);

	/* create example tree */
	CModelSelectionParameters* tree=create_param_tree();
	tree->print();
	SG_SPRINT("----------------------------------\n");

	/* build combinations of parameter trees */
	DynArray<CParameterCombination*> combinations;
	tree->get_combinations(combinations);

	apply_parameter_tree(combinations);

	/* print and directly delete them all */
	for (index_t i=0; i<combinations.get_num_elements(); ++i)
		combinations[i]->destroy(true, true);

	/* delete example tree (after processing of combinations because CSGObject
	 * (namely the kernel) of the tree is SG_UNREF'ed (and not REF'ed anywhere
	 * else) */
	tree->destroy();

	exit_shogun();

	return 0;
}
Example #6
0
// SCWP_Activate
XCALL_ (int) SCWP_Activate( long version, GlobalFunc *global,
                            void *local, void *serverData ) {
  if ( version != LWMODCOMMAND_VERSION )
    return AFUNC_BADVERSION;

  LWModCommand * command = (LWModCommand *)local;
  if( command == NULL )
    return AFUNC_BADLOCAL;

  // Build a list of parts for the selected polygons
  MeshEditOp *op = (command->editBegin)( 0, 0, OPSEL_DIRECT | OPSEL_MODIFY );
  parts.Flush();

  EDError err = op->polyScan( op->state, SCWP_PolyScan_FindParts, (void *)op, OPLYR_FG );
  if( err != EDERR_NONE ) {
    op->done( op->state, err, 0 );
  } else {
    // Select polygons belonging to the selected parts
    err = op->polyScan( op->state, SCWP_PolyScan_Select, (void *)op, OPLYR_FG );
    op->done( op->state, err, 0 );
  }

  // Clean up
  parts.Flush();

  return CSERR_NONE;
}
Example #7
0
// SCWSS_PointScan_FindSets():
EDError SCWSS_PointScan_FindSets( void *_op, const EDPointInfo *point ) {
  MeshEditOp *op = (MeshEditOp *)_op;

  float val;
  if( point->flags & EDDF_SELECT ) {
    for( int v=0; v < vmap_count; v++ ) {
      const char *set_name = object_funcs->vmapName( LWVMAP_PICK, v );
      void       *set_id   = op->pointVSet( op->state, NULL, LWVMAP_PICK, set_name );

      if( op->pointVGet( op->state, point->pnt, &val) != 0 ) {
        unsigned long i;
        for( i=0; i < selection_set_ids.NumElements(); i++ ) {
          if( selection_set_ids[i] == set_id )
            break;
        }

        if( i == selection_set_ids.NumElements() ) {
          selection_set_ids.Add( set_id );
          selection_set_names.Add( StringTools::strdup( set_name ) );
        }
      }
    }
  }

  return EDERR_NONE;
}
void CEntityPropertyHandler::SetProperty(IEntity *pIEntity, int index, const char *value)
{
	EntityId id = pIEntity->GetId();

	CMonoEntityExtension *pEntity = nullptr;
	if (IGameObject *pGameObject = static_cast<CScriptSystem *>(GetMonoScriptSystem())->GetIGameFramework()->GetGameObject(id))
		pEntity = static_cast<CMonoEntityExtension *>(pGameObject->QueryExtension(pIEntity->GetClass()->GetName()));

	// Only true after game has started, limiting this to changes made in Editor.
	if(pEntity && pEntity->IsInitialized())
		pEntity->SetPropertyValue(m_pProperties[index].info, value);
	else
	{
		bool exists = false;
		for(auto it = m_queuedProperties.begin(); it != m_queuedProperties.end(); ++it)
		{
			if((*it).first == id)
			{
				(*it).second.push_back(SQueuedProperty(m_pProperties[index].info, value));

				exists = true;
				break;
			}
		}
		if(!exists)
		{
			DynArray<SQueuedProperty> queuedPropertiesForEntity;
			queuedPropertiesForEntity.push_back(SQueuedProperty(m_pProperties[index].info, value));

			m_queuedProperties.insert(TQueuedPropertyMap::value_type(id, queuedPropertiesForEntity));
		}
	}
}
Example #9
0
void CClipVolumeProxy::UpdateRenderMesh(IRenderMesh* pRenderMesh, const DynArray<Vec3>& meshFaces)
{
	m_pRenderMesh = pRenderMesh;
	gEnv->pEntitySystem->ReleaseBSPTree3D(m_pBspTree);

	const size_t nFaceCount = meshFaces.size() / 3;
	if(nFaceCount > 0)
	{
		IBSPTree3D::FaceList faceList;
		faceList.reserve(nFaceCount);

		for(int i=0; i<meshFaces.size(); i+=3)
		{
			IBSPTree3D::CFace face;
			face.push_back(meshFaces[i + 0]);
			face.push_back(meshFaces[i + 1]);
			face.push_back(meshFaces[i + 2]);

			faceList.push_back(face);
		}

		m_pBspTree = gEnv->pEntitySystem->CreateBSPTree3D(faceList);
	}


	if(m_pEntity && m_pClipVolume)
		gEnv->p3DEngine->UpdateClipVolume(m_pClipVolume, m_pRenderMesh, m_pBspTree, m_pEntity->GetWorldTM(), !m_pEntity->IsHidden(), m_pEntity->GetName());
}
Example #10
0
void KChatSocket::Breathe(int msec)
{
	JgVirtualSocket::Breathe(msec);

	void* packetPtrs[64];
	char packetBuffer[10240];
	DynArray<void*> packets;
	packets.attach(&packetPtrs[0], 64, 0);

	KClientGateListener* cgl = KClientGateListener::getSingletonPtr();

	while(!m_shouldRemove)
	{
		int_r packetNum = this->ReadPackets(packetBuffer, sizeof(packetBuffer), packets, 64);
		if(packetNum < 1) break;
		for(int_r i=0; i<packetNum; i++)
		{
			JgPacketHead* head = (JgPacketHead*)packets[(int)i];
			//cgl->m_gateChatC.Process(this, head);
			if(m_shouldRemove) break;
		}
	}

	if(m_shouldRemove)
	{
		cgl->m_vsocketManager.detach(this);
		m_pGatewaySocket->setChatCnn(NULL);
		Log(LOG_DEBUG, "debug: free %s", this->ToString().c_str());
		this->Destroy();
	}
}
Example #11
0
int StructuredDatabaseTest()
{
	Table* table;
	int user_id;
	DynArray<1024> what;
	DynArray<1024> where;

	table = new Table(&database, "structured_test");
	table->Truncate();
	user_id = InsertUser(table, "dopey", "dopeypass", "online");
	InsertEvent(table, user_id, "dinner", "cheezburger", "2009-03-24 01:09:00");
	InsertEvent(table, user_id, "meeting", "important", "2009-03-24 11:12:00");

	// SELECT * FROM event WHERE user=%d AND date > 2009-03-24 01
	what.Printf("event:user:%d", user_id);
	where.Printf("date:2009-03-24 01");
	//TableSelector selector(what.buffer, where.buffer);
//	QuerySelector selector("SELECT date, note FROM event WHERE user_id=%d", user_id);
//	table->Visit(selector);

	ListTableVisitor visitor;
	table->Visit(visitor);
	
	return TEST_SUCCESS;
}
Example #12
0
bool Endpoint::Set(const char* ip_port, bool resolv)
{
	const char*		p;
	int				port;
	bool			ret;
	DynArray<32>	ipbuf;

	p = ip_port;
	
	while (*p != '\0' && *p != ':')
		p++;
	
	if (*p == '\0')
	{
		Log_Trace("No ':' in host specification");
		return false;
	}

	ipbuf.Append(ip_port, p - ip_port);
	ipbuf.Append("", 1);
	p++;
	
	port = -1;
	port = atoi(p);
	if (port < 1 || port > 65535)
	{
		Log_Trace("atoi() failed to produce a sensible value");
		return false;
	}

	ret = Set(ipbuf.buffer, port, resolv);
	
	return ret;
}
Example #13
0
void SimpleSortedSetData< KeyT, CompareKeyT, AllocatorT >::Serialize( ArchiveT& archive )
{
    DynArray< ObjectPtr > components;
    components.Reserve( m_Data->GetSize() );

    {
        DataType::ConstIterator itr = m_Data->Begin();
        DataType::ConstIterator end = m_Data->End();
        for ( ; itr != end; ++itr )
        {
            ObjectPtr dataElem = Registry::GetInstance()->CreateInstance( Reflect::GetDataClass< KeyT >() );

            // downcast to data type
            Data* dataSer = AssertCast< Data >( dataElem );

            // connect to our map data memory address
            dataSer->ConnectData( const_cast< KeyT* >( &( *itr ) ) );

            // serialize to the archive stream
            HELIUM_VERIFY( components.New( dataSer ) );
        }
    }

    archive.SerializeArray( components );

    DynArray< ObjectPtr >::Iterator itr = components.Begin();
    DynArray< ObjectPtr >::Iterator end = components.End();
    for ( ; itr != end; ++itr )
    {
        Data* ser = AssertCast< Data >( *itr );
        ser->Disconnect();

        // might be useful to cache the data object here
    }
}
Example #14
0
void SimpleObjectSortedMapData< KeyT, CompareKeyT, AllocatorT >::Deserialize( ArchiveT& archive )
{
    DynArray< ObjectPtr > components;
    archive.DeserializeArray( components, ArchiveFlags::Sparse );

    size_t componentCount = components.GetSize();
    if ( componentCount % 2 != 0 )
    {
        throw Reflect::DataFormatException( TXT( "Unmatched map objects" ) );
    }

    // if we are referring to a real field, clear its contents
    m_Data->Clear();
    m_Data->Reserve( componentCount / 2 );

    DynArray< ObjectPtr >::Iterator itr = components.Begin();
    DynArray< ObjectPtr >::Iterator end = components.End();
    while ( itr != end )
    {
        Data* key = SafeCast< Data >( *itr );
        ++itr;
        Object* value = *itr;
        ++itr;

        if ( key )  // The object value can be null, so don't check it here.
        {
            KeyT k;
            Data::GetValue( key, k );
            (*m_Data)[ k ] = value;
        }
    }
}
Example #15
0
void Boot::boot_run() const
 {
  DynArray<unsigned> boot;
  
  buildBoot(boot,Range(&__std_boot_beg,&__std_boot_end));

  __std_boot(boot.getPtr(),boot.getPtr()+boot.getLen());
 }
Example #16
0
/// Resolve a set of shader preprocessor options from the associated index.
///
/// @param[in]  shaderType    Type of shader.
/// @param[in]  index         Option set index.
/// @param[out] rToggleNames  List of enabled shader toggles.
/// @param[out] rSelectPairs  List shader selection pair values.
void Shader::Options::GetOptionSetFromIndex(
    RShader::EType shaderType,
    size_t index,
    DynArray< Name >& rToggleNames,
    DynArray< SelectPair >& rSelectPairs ) const
{
    HELIUM_ASSERT( static_cast< size_t >( shaderType ) < static_cast< size_t >( RShader::TYPE_MAX ) );

    rToggleNames.Resize( 0 );
    rSelectPairs.Resize( 0 );

    uint32_t shaderTypeMask = ( 1 << shaderType );

    size_t shaderToggleCount = m_toggles.GetSize();
    for( size_t shaderToggleIndex = 0; shaderToggleIndex < shaderToggleCount; ++shaderToggleIndex )
    {
        const Toggle& rShaderToggle = m_toggles[ shaderToggleIndex ];
        if( !( rShaderToggle.shaderTypeFlags & shaderTypeMask ) )
        {
            continue;
        }

        if( index & 0x1 )
        {
            HELIUM_VERIFY( rToggleNames.New( rShaderToggle.name ) );
        }

        index >>= 1;
    }

    size_t shaderSelectCount = m_selects.GetSize();
    for( size_t shaderSelectIndex = 0; shaderSelectIndex < shaderSelectCount; ++shaderSelectIndex )
    {
        const Select& rShaderSelect = m_selects[ shaderSelectIndex ];
        if( !( rShaderSelect.shaderTypeFlags & shaderTypeMask ) )
        {
            continue;
        }

        const DynArray< Name >& rShaderSelectChoices = rShaderSelect.choices;
        size_t shaderSelectChoiceCount = rShaderSelectChoices.GetSize();

        size_t selectIndexMultiplier = shaderSelectChoiceCount + rShaderSelect.bOptional;

        size_t selectIndex = index % selectIndexMultiplier;
        index /= selectIndexMultiplier;

        if( !rShaderSelect.bOptional || selectIndex != shaderSelectChoiceCount )
        {
            SelectPair* pSelectPair = rSelectPairs.New();
            HELIUM_ASSERT( pSelectPair );
            pSelectPair->name = rShaderSelect.name;
            pSelectPair->choice = rShaderSelectChoices[ selectIndex ];
        }
    }
}
Example #17
0
Reflect::ObjectPtr Helium::Cache::ReadCacheObjectFromBuffer( const DynArray< uint8_t > &_buffer )
{
    if (_buffer.GetSize() == 0)
    {
        Reflect::ObjectPtr null_object;
        return null_object;
    }

    return ReadCacheObjectFromBuffer(_buffer.GetData(), 0, _buffer.GetSize());
}
Example #18
0
	int count(const char* key){
		DynArray<int> * a = valarray->get(keys->indexofVal(key));
		int count = 0;
		for(int i = 0; i<a->getLength();i++){
			if(a->get(i) >= 0){
				count++;
			}	
		}
		return count;
	}
Example #19
0
   BuilderSlot & take(ulen slot_id)
    {
     ulen len=bslots.getLen();

     if( slot_id>=len )
       {
        bslots.extend_default(LenAdd(slot_id-len,1));
       }

     return bslots[slot_id];
    }
Example #20
0
void SimpleSortedSetData< KeyT, CompareKeyT, AllocatorT >::GetItems( DynArray< DataPtr >& items ) const
{
    items.Clear();
    items.Reserve( m_Data->GetSize() );

    DataType::ConstIterator itr = m_Data->Begin();
    DataType::ConstIterator end = m_Data->End();
    for ( ; itr != end; ++itr )
    {
        HELIUM_VERIFY( items.New( Data::Bind( const_cast< KeyT& >( *itr ), m_Instance, m_Field ) ) );
    }
}
void CFlashUIGetCompatibleAccessoriesNode ::ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo )
{
	if(event == eFE_Activate && IsPortActive(pActInfo, 0))
	{
		string accessories = "";
		IActor* pActor = GetInputActor( pActInfo );

		if(pActor)
		{
			IInventory* pInventory = pActor->GetInventory();
			if(pInventory)
			{
				//Get the item ID via the Input string
				const string weapon_name = GetPortString(pActInfo, eI_Weapon);
				IEntityClassRegistry *pRegistery = gEnv->pEntitySystem->GetClassRegistry();
				EntityId item = pInventory->GetItemByClass(pRegistery->FindClass(weapon_name));

				//Fetch the actual weapon via the ID
				IEntity* pEntity = gEnv->pEntitySystem->GetEntity(item);
				if(pEntity)
				{

					CGameObject * pGameObject = (CGameObject*)pEntity->GetProxy(ENTITY_PROXY_USER);
					const char* ext = pGameObject->GetEntity()->GetClass()->GetName();
					CWeapon* pWeapon = (CWeapon*)pGameObject->QueryExtension(pGameObject->GetEntity()->GetClass()->GetName());

					//If the weapon exists, ask for all compatible accessories
					if(pWeapon)
					{
						//All compatible accessories for this weapon
						const DynArray<string> pCompatibleAccessoriesVec = pWeapon->GetCompatibleAccessories();

						bool first = true;
						DynArray<string>::const_iterator it;
						for (it = pCompatibleAccessoriesVec.begin(); it != pCompatibleAccessoriesVec.end(); it++)
						{
							if (!first)
								accessories.append(",");
							accessories.append((*it));
							first = false;
						}
					}
				}
			}
		}

		//return, if 'accessories' is empty, it has no compatible attachments, or the weapon/inventory was invalid
		ActivateOutput(pActInfo, eO_OnCall, true);
		ActivateOutput(pActInfo, eO_Args, accessories);
	}
}
Example #22
0
int main (int argl, char ** argc) {
	
	DynArray <char *> files;
	
	for (int i=1; i<argl; ++i) {
		if (argc [i][0] == '-') {
			if (string (argc [i]) == "--help") {
				printHelp (argc [0]);
				return 0;
			}
		} else {
			files.push_back (argc [i]);
		}
	}
	
	if (files.empty ()) {
		
		string line, prog;
		while (std::getline (std::cin, line)) {
			if (not line.empty ()) {
				prog += line + "\n";
			} else if (not prog.empty ()) {
				auto n = parse (prog);
				print (n);
				delete n;
				std::cout << std::endl;
				prog = line;
			}
		}
		if (not prog.empty()) {
			auto n = parse (prog);
			print (n);
			delete n;
		}
		
	} else {
		for (char * f : files) {
			std::ifstream fin (f);
			string buff, prog;
			while (std::getline (fin, buff)) prog += buff + "\n";
			std::cout << "########" << f << "########" << std::endl;
			auto n = parse (prog);
			print (n);
			delete n;
			std::cout << "########" << f << "########" << std::endl;
		}
	}
	
	return 0;
	
}
Example #23
0
void StructureDynArrayData::Serialize( ArchiveT& archive )
{
    const Structure *structure = GetInternalStructure();

    DynArray< ObjectPtr > components;
    components.Resize( structure->m_DynArrayAdapter->GetSize(GetInternalPtr(structure)) );

    for (size_t i = 0; i < components.GetSize(); ++i)
    {
        components[i] = structure->m_DynArrayAdapter->GetItem(GetInternalPtr(structure), i, m_Instance, m_Field);
    }

    archive.SerializeArray( components );
}
Example #24
0
void CEditorGame::InitLevelTypesEnums(IGameToEditorInterface* pGTE)
{
	DynArray<string>* levelTypes;
	levelTypes = g_pGame->GetIGameFramework()->GetILevelSystem()->GetLevelTypeList();
	
	const char** allLevelTypes = new const char*[levelTypes->size()];
	for (int i = 0; i < levelTypes->size(); i++)
	{
		PREFAST_ASSUME(i > 0 && i < levelTypes->size());
		allLevelTypes[i] = (*levelTypes)[i];
	}

	pGTE->SetUIEnums("level_types", allLevelTypes, levelTypes->size());
	delete[] allLevelTypes;
}
Example #25
0
void StructureDynArrayData::Deserialize( ArchiveT& archive )
{
    const Structure *structure = GetInternalStructure();

    DynArray< ObjectPtr > components;
    archive.DeserializeArray(components);

    // if we are referring to a real field, clear its contents
    structure->m_DynArrayAdapter->Resize(GetInternalPtr(structure), components.GetSize());

    for (size_t i = 0; i < components.GetSize(); ++i)
    {
        Data* data = SafeCast<Data>(components[i]);
        structure->m_DynArrayAdapter->SetItem(GetInternalPtr(structure), i, data, m_Instance, m_Field);
    }
}
GT create_graph()
{
  GT g;
  DynArray<typename GT::Node*> nodes; nodes.reserve(V);
  for (int i = 0; i < V; ++i)
    nodes(i) = g.insert_node(i);

  for (int i = 0; i < V - 1; ++i)
    {
      typename GT::Node * src = nodes(i);
      for (int j = i + 1; j < V; ++j)
	g.insert_arc(src, nodes(j), i + j);
    }

  return std::move(g);
}
Example #27
0
bool CFlowGraphDebugger::GetBreakpoints(DynArray<SBreakPoint>& breakpointsDynArray)
{
	if (m_DebugInfo.empty())
	{
		return false;
	}

	TDebugInfo::const_iterator iterDebugInfo = m_DebugInfo.begin();

	for (iterDebugInfo; iterDebugInfo != m_DebugInfo.end(); ++iterDebugInfo)
	{
		TFlowNodesDebugInfo flownodesDebugInfo = (*iterDebugInfo).second;
		TFlowNodesDebugInfo::const_iterator iterNodesDebugInfo = flownodesDebugInfo.begin();

		for (iterNodesDebugInfo; iterNodesDebugInfo != flownodesDebugInfo.end(); ++iterNodesDebugInfo)
		{
			SBreakPoints breakpoints = (*iterNodesDebugInfo).second;
			// Fill with INPUT port breakpoints
			FillDynArray(breakpointsDynArray, breakpoints.inputPorts, (*iterDebugInfo).first, (*iterNodesDebugInfo).first, false);
			// Fill with OUTPUT port breakpoints
			FillDynArray(breakpointsDynArray, breakpoints.outputPorts, (*iterDebugInfo).first, (*iterNodesDebugInfo).first, true);
		}
	}

	if (breakpointsDynArray.empty())
	{
		return false;
	}

	return true;
}
Example #28
0
INT_PTR CALLBACK SquerProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;
	TCHAR szText[80];

	wsprintf(szText, _T("HELLO WORLD!"));
	UNREFERENCED_PARAMETER(lParam);
	switch (message)
	{
	case WM_INITDIALOG:
		return (INT_PTR)TRUE;

	case WM_COMMAND:
		wmId = LOWORD(wParam);
		wmEvent = HIWORD(wParam);
		// Parse the menu selections:
		switch (wmId)
		{
		case IDOK:
		{
					 int x1 = GetDlgItemInt(hDlg, IDC_X1, 0, 0);
					 int y1 = GetDlgItemInt(hDlg, IDC_Y1, 0, 0);
					 int x2 = GetDlgItemInt(hDlg, IDC_X2, 0, 0);
					 int y2 = GetDlgItemInt(hDlg, IDC_Y2, 0, 0);
					pic.Add(new Squer(Point(x1, y1), Point(x2, y2)));
		}
		case IDCANCEL:
			EndDialog(hDlg, wmId);
			return (INT_PTR)TRUE;
		}
		break;
	}
	return (INT_PTR)FALSE;
}
Example #29
0
INT_PTR CALLBACK CircleProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;

	UNREFERENCED_PARAMETER(lParam);
	switch (message)
	{
	case WM_INITDIALOG:
		return (INT_PTR)TRUE;

	case WM_COMMAND:
		wmId = LOWORD(wParam);
		wmEvent = HIWORD(wParam);
		// Parse the menu selections:
		switch (wmId)
		{
		case IDOK:
		{
					 int x = GetDlgItemInt(hDlg, IDC_X, 0, 0);
					 int y = GetDlgItemInt(hDlg, IDC_Y, 0, 0);
					 int r = GetDlgItemInt(hDlg, IDC_RADIUS, 0, 0);
					 pic.Add(new Circle(Point(x,y), r));
		}
		case IDCANCEL:
			EndDialog(hDlg, wmId);
			return (INT_PTR)TRUE;
		}
		break;
	}
	return (INT_PTR)FALSE;
}
Example #30
0
void Boot::boot_flash(ulen off) const
 {
  DynArray<unsigned> boot;
  
  buildBoot(boot);

  const unsigned WS = sizeof (unsigned) ; // 4, unsigned == uint32

  if( boot.getLen()>(MaxFlashLen-BootDataOff)/WS )
    {
     Printf(Exception,"CCore::Boot::boot_flash() : too large boot");
    }
    
  ulen len=boot.getLen()*WS+BootDataOff;  
  
  ulen block_count=(len+Flash::BlockSize-1)/Flash::BlockSize;
  
  ulen block_index=off/Flash::BlockSize;
  
  for(ulen ind=block_index,lim=ind+block_count; ind<lim ;ind++) 
    if( !Flash::Erase(ind) )
      {
       Flash::ReadMode();
      
       Printf(Exception,"CCore::Boot::boot_flash() : flash erase failure");
      }
    else
      {
       Printf(Con,"Block #; erased\n",ind);
      }  
      
  if( !Flash::Write(off+BootDataOff,Range_const(boot)) )   
    {
     Flash::ReadMode();
    
     Printf(Exception,"CCore::Boot::boot_flash() : flash write failure");
    }
    
  PtrLen<const uint32> boot_code=Range(&__std_bootflash_beg,&__std_bootflash_end);  
    
  if( !Flash::Write(off,boot_code) )   
    {
     Flash::ReadMode();
    
     Printf(Exception,"CCore::Boot::boot_flash() : flash write failure");
    }
 }