Daily Archives

Articles indexed Saturday April 10 2010

Page 16/89 | < Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >

  • C++ design question, container of instances and pointers

    - by Tom
    Hi all, Im wondering something. I have class Polygon, which composes a vector of Line (another class here) class Polygon { std::vector<Line> lines; public: const_iterator begin() const; const_iterator end() const; } On the other hand, I have a function, that calculates a vector of pointers to lines, and based on those lines, should return a pointer to a Polygon. Polygon* foo(Polygon& p){ std::vector<Line> lines = bar (p.begin(),p.end()); return new Polygon(lines); } Here's the question: I can always add a Polygon (vector Is there a better way that dereferencing each element of the vector and assigning it to the existing vector container? //for line in vector<Line*> v //vcopy is an instance of vector<Line> vcopy.push_back(*(v.at(i)) I think not, but I dont really like that approach. Hopefully, I will be able to convince the author of the class to change it, but I cant base my coding right now to that fact (and i'm scared of a performance hit). Thanks in advance.

    Read the article

  • Scala contiguous match

    - by drypot
    pathTokens match { case List("post") => ("post", "index") case List("search") => ("search", "index") case List() => ("home", "index") } match { case (controller, action) => loadController(http, controller, action) case _ => null } I wanted contiguous match. but got compile error. :( (pathTokens match { case List("post") => ("post", "index") case List("search") => ("search", "index") case List() => ("home", "index") }) match { case (controller, action) => loadController(http, controller, action) case _ => null } When I wrapped first match with parenparenthesis, it worked ok. Why I need parenthesis here ?

    Read the article

  • C++ design question, container of instances and pointers

    - by Tom
    Hi all, Im wondering something. I have class Polygon, which composes a vector of Line (another class here) class Polygon { std::vector<Line> lines; public: const_iterator begin() const; const_iterator end() const; } On the other hand, I have a function, that calculates a vector of pointers to lines, and based on those lines, should return a pointer to a Polygon. Polygon* foo(Polygon& p){ std::vector<Line> lines = bar (p.begin(),p.end()); return new Polygon(lines); } Here's the question: I can always add a Polygon (vector Is there a better way that dereferencing each element of the vector and assigning it to the existing vector container? //for line in vector<Line*> v //vcopy is an instance of vector<Line> vcopy.push_back(*(v.at(i)) I think not, but I dont really like that approach. Hopefully, I will be able to convince the author of the class to change it, but I cant base my coding right now to that fact (and i'm scared of a performance hit). Thanks in advance.

    Read the article

  • Wpf combobox selection change breaks Datatrigger

    - by biju
    Hi, I am trying to set the selected value of a combobox from a style trigger.It works as long as we dont manually change any value in the combobox.But it stops working altogether after manually changing the selection.How can i solve this.A sample code is attached.Please do help <Window x:Class="InputGesture.Window2" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:InputGesture" Title="Window2" Height="300" Width="300" Name="Sample"> <Window.Resources> <Style TargetType="{x:Type ComboBox}"> <Setter Property="ComboBox.SelectedValue" Value="1"/> <Style.Triggers> <DataTrigger Binding="{Binding ElementName=chk,Path=IsChecked}" Value="True"> <Setter Property="ComboBox.IsEnabled" Value="False"/> <Setter Property="ComboBox.SelectedValue" Value="2"/> </DataTrigger> </Style.Triggers> </Style> </Window.Resources> <StackPanel> <CheckBox Name="chk" Height="23"/> <ComboBox Name="cmb" Height="23" DisplayMemberPath="Name" SelectedValuePath="Id" ItemsSource="{Binding ElementName=Sample,Path=DT}"> </ComboBox> <Button Height="23" Click="Button_Click"/> </StackPanel> </Window>

    Read the article

  • EJB3 - using 2 persistence units within a transaction (Exception: Local transaction already has 1 no

    - by Sorcha
    I am trying to use 2 persistence units within the same transaction in a JEE application deployed on Glassfish. The 2 persistence units are defined in persistence.xml, as follows: <persistence-unit name="BeachWater"> <jta-data-source>jdbc/BeachWater</jta-data-source> ... <persistence-unit name="LIMS"> <jta-data-source>jdbc/BeachWaterLIMS</jta-data-source> ... These persistence units correspond to JDBC resources and connection pools which I had defined in Glassfish as follows (include one here as both are identical apart from names & database connection info): JDBC Resource: JNDI Name: jdbc/BeachWaterLIMS Pool Name: BEACHWATER_LIMS Connection Pool: Name: BEACHWATER_LIMS Datasource Classname: com.microsoft.sqlserver.jdbc.SQLServerConnectionPoolDataSource Resource Type: javax.sql.ConnectionPoolDataSource There are 3 stateless session beans, LimsServiceBean, AnalysisServiceBean and AnalysisDataTransformationServiceBean. Here are the relevant snippets from LimsServiceBean: @PersistenceContext(unitName = "LIMS") EntityManager em; ... public ArrayList<Sample> getLatestLIMSData() { Query q = em.createNamedQuery("Sample.findBySubTypeStatus"); return new ArrayList<Sample>(q.getResultList()); } From AnalysisServiceBean: @PersistenceContext(unitName = "BeachWater") EntityManager em; ... public ArrayList<AnalysisType> getAllAnalysisTypes() { Query q = em.createNamedQuery("AnalysisType.findAll"); return new ArrayList<AnalysisType>(q.getResultList()); } And from AnalysisDataTransformationServiceBean: @EJB private AnalysisService analysisService; @EJB private LimsService limsService; public void transformData() { List<AnalysisType> analysisTypes = analysisService.getAllAnalysisTypes(); ArrayList<Sample> samples = limsService.getLatestLIMSData(); This call to limsService.getLatestLIMSData() caused the following exception: [exec] Caused by: javax.ejb.TransactionRolledbackLocalException: Exception thrown from bean; nested exception is: Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.1 (Build b60e-fcs (12/23/2008))): oracle.toplink.essentials.exceptions.DatabaseException [exec] Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: java.lang.IllegalStateException: Local transaction already has 1 non-XA Resource: cannot add more resources. Having consulted this page, http://msdn.microsoft.com/en-us/library/ms378484.aspx (among many others), I tried changing the definition of the connection pools to: Connection Pool: Name: BEACHWATER_LIMS Datasource Classname: com.microsoft.sqlserver.jdbc.SQLServerXADataSource Resource Type: javax.sql.XADataSource Ping via the Glassfish admin console succeeds, but call to analysisService.getAllAnalysisTypes() now throws an exception: Caused by: javax.ejb.TransactionRolledbackLocalException: Exception thrown from bean; nested exception is: Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.1 (Build b60e-fcs (12/23/2008))): oracle.toplink.essentials.exceptions.DatabaseException Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: javax.transaction.SystemException Any ideas?

    Read the article

  • iPhone App not saving values to .plist file

    - by Trent
    Hey everyone. I am working on an app that displays a modal the first time the consumer uses it. I have a .plist file that will store the information I request once the Save button is pressed. I can read from the .plist file fine and when I run my save method it SEEMS to work fine but the .plist file is not updating. I'm not so sure of the problem here. I show the modal like this. - (void) getConsumerInfo { NSString *filePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"consumer.plist"]; NSMutableDictionary *plistConsumerInfo = [[NSMutableDictionary alloc] initWithContentsOfFile:filePath]; NSString *hasAppeared = [plistConsumerInfo objectForKey:@"HasAppeared"]; if(hasAppeared != kHasAppeared) { ConsumerInfoViewController *tmpConsumerInfoVC = [[ConsumerInfoViewController alloc] initWithNibName:@"ConsumerInfoView" bundle:nil]; self.consumerInfoViewController = tmpConsumerInfoVC; [self presentModalViewController:consumerInfoViewController animated:YES]; [tmpConsumerInfoVC release]; } } This is called by the viewDidLoad method in the first view phone when the app is started. Within the consumerInfoViewController I have textfields that have data entered and when the Save button is pressed it calls this method. - (IBAction)saveConsumerInfo:(id)sender { NSString *filePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"consumer.plist"]; NSMutableDictionary *plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile:filePath]; NSString *tmpDiversName = txtDiversName.text; NSString *tmpLicenseType = txtLicenseType.text; NSString *tmpLicenseNum = txtLicenseNumber.text; NSString *tmpHasAppeared = @"1"; NSString *tmpNumJumps = @"3"; [plistDict setValue:[[NSString alloc] initWithFormat:@"%@", tmpDiversName] forKey:@"ConsumerName"]; [plistDict setValue:[[NSString alloc] initWithFormat:@"%@", tmpLicenseType] forKey:@"LicenseType"]; [plistDict setValue:[[NSString alloc] initWithFormat:@"%@", tmpLicenseNum] forKey:@"LicenseNumb"]; [plistDict setValue:[[NSString alloc] initWithFormat:@"%@", tmpNumJumps] forKey:@"NumJumps"]; [plistDict setValue:[[NSString alloc] initWithFormat:@"%d", tmpHasAppeared] forKey:@"Show"]; [plistDict writeToFile:filePath atomically: YES]; NSLog([[NSString alloc] initWithContentsOfFile:filePath]); [self dismissModalViewControllerAnimated:YES]; } This all runs fine with no hiccups but the file is never updated. I would like it to update so I can use this information throughout the app and update the flag so it will not show the view again once the data is entered. Please let me know if there is anymore information you need. Thanks in advance!

    Read the article

  • How to return DropDownList selections dynamically in C#?

    - by salvationishere
    This is probably a simple question but I am developing a web app in C# with DropDownList. Currently it is working for just one DropDownList. But now that I modified the code so that number of DropDownLists that should appear is dynamic, it gives me error; "The name 'ddl' does not exist in the current context." The reason for this error is that there a multiple instances of 'ddl' = number of counters. So how do I instead return more than one 'ddl'? Like what return type should this method have instead? And how do I return these values? Reason I need it dynamic is I need to create one DropDownList for each column in whatever Adventureworks table they select. private DropDownList CreateDropDownLists() { for (int counter = 0; counter < NumberOfControls; counter++) { DropDownList ddl = new DropDownList(); SqlDataReader dr2 = ADONET_methods.DisplayTableColumns(targettable); ddl.ID = "DropDownListID" + (counter + 1).ToString(); int NumControls = targettable.Length; DataTable dt = new DataTable(); dt.Load(dr2); ddl.DataValueField = "COLUMN_NAME"; ddl.DataTextField = "COLUMN_NAME"; ddl.DataSource = dt; ddl.ID = "DropDownListID 1"; ddl.SelectedIndexChanged += new EventHandler(ddlList_SelectedIndexChanged); ddl.DataBind(); ddl.AutoPostBack = true; ddl.EnableViewState = true; //Preserves View State info on Postbacks //ddlList.Style["position"] = "absolute"; //ddl.Style["top"] = 80 + "px"; //ddl.Style["left"] = 0 + "px"; dr2.Close(); } return ddl; }

    Read the article

  • how to change windowXP theme using vb.net2005

    - by Darshna Raghani
    I have tried the following code but has no effect: Imports system.Runtime.InteropServices <DllImport("UxTheme.DLL", BestFitMapping:=False, CallingConvention:=CallingConvention.Winapi, CharSet:=CharSet.Unicode, EntryPoint:="#65")> _ Shared Function SetSystemVisualStyle(ByVal pszFilename As String, ByVal pszColor As String, ByVal pszSize As String, ByVal dwReserved As Integer) As Integer End Function Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 'This code will set Window Themes SetSystemVisualStyle("C:\WINDOWS\Resources\Themes\HmmXP_2_0_1\HmmXP\HmmXP.msstyles", "NormalColor", "NormalSize", 0) End Sub Can anyone plz help?

    Read the article

  • Flex DownloadProgressBar preloader override

    - by Shawn Simon
    I'm watching this video, which is pretty good http://www.gotoandlearn.com/play?id=108 It shows how to inherit from DownloadProgressBar to create a customer preloader for your flex app. The DownloadProgressBar class has an overridable getter for the property 'preloader.' Isn't this poor design? What does a property called preloader have anything to do with a class for a DownloadProgressBar?

    Read the article

  • How to do interactive with the prompt this way in PHP?

    - by user198729
    C:\>mysql -uroot -padmin Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 6 Server version: 5.0.37-community-nt-log MySQL Community Edition (GPL) Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> show databases -> ; +--------------------+ | Database | +--------------------+ | information_schema | | attendance | | fusionchartsdb | | mysql | | sugarcrm | | test | +--------------------+ 6 rows in set (0.09 sec) mysql> use mysql; Database changed mysql> So I want to start a process by mysql -uroot -padmin,and in that process I want to run these statements: show databases use mysql insert xxx (..) values (..) How to do it in PHP?

    Read the article

  • Python Comet Server

    - by HenryL
    I am building a web application that has a real-time feed (similar to Facebook's newsfeed) that I want to update via a long-polling mechanism. I understand that with Python, my choices are pretty much to either use Stackless (building from their Comet wsgi example) or Cometd + Twisted. Unfortunately there is very little documentation regarding these options and I cannot find good information online about production scale users of comet on Python. Has anyone successfully implemented comet on Python in a production system? How did you go about doing it and where can I find resources to implement my own?

    Read the article

  • basic boost date_time input format question

    - by Chris H
    I've got a pointer to a string, (char *) as input. The date/time looks like this: Sat, 10 Apr 2010 19:30:00 I'm only interested in the date, not the time. I created an "input_facet" with the format I want: boost::date_time::date_input_facet inFmt("%a %d %b %Y"); but I'm not sure what to do with it. Ultimately I'd like to create a date object from the string. I'm pretty sure I'm on the right track with that input facet and format, but I have no idea how to use it. Thanks.

    Read the article

  • Using Jquery UI Tab control in ASP.NET MVC

    - by mike3333
    I am new to jquery and am trying out UI plugins. For some reason this following code does not work, in the sense, it does not render the tabs and it's just a bunch of text. But when I copy the page source and paste it in the html page, and put it in the views folder, everything looks great, so , I assume all the js paths are good. Any ideas? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> Details $(document).ready(function() { $("#tabs").tabs(); }); <div id="tabs"> <ul> <li><a href="#tabs-1">Text 1</a></li> <li><a href="#tabs-2">Text 2</a></li> <li><a href="#tabs-3">Text 3</a></li> </ul> <div id="tabs-1"> <div>tab1 content - adsfadfadsf</div> </div> <div id="tabs-2"> <div>tab 2 content -adfadfadf </div> </div> <div id="tabs-3"> <div>tab 3 content -adfadfadfadf</div> </div> </div> </div>

    Read the article

  • How invoke live method with arguments

    - by dorelal
    I am learning how to write jQuery plugin. So why I am doing what I am doing does not matter. I writing a plugin called live2 which does nothing else but internally calls live method. (function($) { $.fn.live2 = function() { /* if there are no elements then just return */ if (!this.length) return this; return this.each(function() { var $this = $(this); jQuery.fn.live.apply(this, arguments); }); // end of return this.each(function()) }; // end of plugin })(jQuery); Above code should be invoked just live any live method. Instead of live use live2. $('#container').live2('click',function(){ return false; }) But the plugin is not working. Any idea what the fix should be.

    Read the article

  • rdoc and the "--accessor" option

    - by Brian Ploetz
    rdoc --help says: --accessor, -A accessorname[,..] comma separated list of additional class methods that should be treated like 'attr_reader' and friends. Option may be repeated. Each accessorname may have '=text' appended, in which case that text appears where the r/w/rw appears for normal accessors. Does anyone have any working examples of doing this (both the accessor method definition and the rdoc command invocation)? No matter what combination I try, my accessors will not show up in the RDoc output. Thanks.

    Read the article

  • How can I take a photo from my camera phone remotely? [closed]

    - by kurt
    Is there any app where I could control the camera of my phone remotely(even bluetooth would do) I have a Nokia 5800 xpress music. The app could either be a stand alone app installed on the mobile phone than could click snaps at predefined intervals or if there is a app that I can install on my PC and then control my phone's camera via bluetooth or wifi or anything else. Is this possible?

    Read the article

  • is there such a thing as a ip femtocell, and what does it do?

    - by The Journeyman geek
    My dad mentioned a co-worker suggested using a device, that might use cdma to route calls through IP to save costs on a certain overseas project we're on- since our home base is quite far from there. I've never heard of such a device, so if it does, i'm wondering, if its specific to particular ISPs, or if you can just pick one off the shelf, plug it into an arbitraty internet connection, and make calls using it and a cellphone of some sort? As you can tell, details are sketchy, so... if such a device dosen't exist, saying so might be a right answer ;)

    Read the article

  • Installing a python wrapper for a c++ library

    - by Eugene Kogan
    Hi all, I am trying to install the python wrapper for the ANN (approx near neighbors) c++ library: link is http://www.scipy.org/scipy/scikits/wiki/AnnWrapper . I am on Windows 7 32-bit. Unfortunately the documentation is a bit terse and I am a newbie to programming in general, so I cannot decipher the instructions found within. I have not built a C++ library before and am not even sure how to get that far. Can anyone please guide? Thanks! gene

    Read the article

  • convert RGB values to equivalent HSV values using python

    - by sree01
    Hi, I want to convert RGB values to HSV using python. I got some code samples, which gave the result with the S and V values greater than 100. (example : http://code.activestate.com/recipes/576554-covert-color-space-from-hsv-to-rgb-and-rgb-to-hsv/ ) . anybody got a better code which convert RGB to HSV and vice versa thanks

    Read the article

< Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >