Search Results

Search found 6420 results on 257 pages for 'mathieu parent'.

Page 44/257 | < Previous Page | 40 41 42 43 44 45 46 47 48 49 50 51  | Next Page >

  • Customizing configuration with Dependency Injection

    - by mathieu
    I'm designing a small application infrastructure library, aiming to simplify development of ASP.NET MVC based applications. Main goal is to enforce convention over configuration. Hovewer, I still want to make some parts "configurable" by developpers. I'm leaning towards the following design: public interface IConfiguration { SomeType SomeValue; } // this one won't get registered in container protected class DefaultConfiguration : IConfiguration { public SomeType SomeValue { get { return SomeType.Default; } } } // declared inside 3rd party library, will get registered in container protected class CustomConfiguration : IConfiguration { public SomeType SomeValue { get { return SomeType.Custom; } } } And the "service" class : public class Service { private IConfiguration conf = new DefaultConfiguration(); // optional dependency, if found, will be set to CustomConfiguration by DI container public IConfiguration Conf { get { return conf; } set { conf = value; } } public void Configure() { DoSomethingWith( Conf ); } } There, the "configuration" part is clearly a dependency of the service class, but it this an "overuse" of DI ?

    Read the article

  • Count unique visitors by group of visited places

    - by Mathieu
    I'm facing the problem of counting the unique visitors of groups of places. Here is the situation: I have visitors that can visit places. For example, that can be internet users visiting web pages, or customers going to restaurants. A visitor can visit as much places as he wishes, and a place can be visited by several visitors. A visitor can come to the same place several times. The places belong to groups. A group can obviously contain several places, and places can belong to several groups. Given that, for each visitor, we can have a list of visited places, how can I have the number of unique visitors per group of places? Example: I have visitors A, B, C and D; and I have places x, y and z. I have these visiting lists: [ A -> [x,x,y,x], B -> [], C -> [z,z], D -> [y,x,x,z] ] Having these number of unique visitors per place is quite easy: [ x -> 2, // A and D visited x y -> 2, // A and D visited y z -> 2 // C and D visited z ] But if I have these groups: [ G1 -> [x,y,z], G2 -> [x,z], G3 -> [x,y] ] How can I have this information? [ G1 -> 3, // A, C and D visited x or y or z G2 -> 3, // A, C and D visited x or z G3 -> 2 // A and D visited x or y ] Additional notes : There are so many places that it is not possible to store information about every possible group; It's not a problem if approximation are made. I don't need 100% precision. Having a fast algorithm that tells me that there were 12345 visits in a group instead of 12543 is better than a slow algorithm telling the exact number. Let's say there can be ~5% deviation. Is there an algorithm or class of algorithms that addresses this type of problem?

    Read the article

  • Programmatically disclosing a node in af:tree and af:treeTable

    - by Frank Nimphius
    A common developer requirement when working with af:tree or af:treeTable components is to programmatically disclose (expand) a specific node in the tree. If the node to disclose is not a top level node, like a location in a LocationsView -> DepartmentsView -> EmployeesView hierarchy, you need to also disclose the node's parent node hierarchy for application users to see the fully expanded tree node structure. Working on ADF Code Corner sample #101, I wrote the following code lines that show a generic option for disclosing a tree node starting from a handle to the node to disclose. The use case in ADF Coder Corner sample #101 is a drag and drop operation from a table component to a tree to relocate employees to a new department. The tree node that receives the drop is a department node contained in a location. In theory the location could be part of a country and so on to indicate the depth the tree may have. Based on this structure, the code below provides a generic solution to parse the current node parent nodes and its child nodes. The drop event provided a rowKey for the tree node that received the drop. Like in af:table, the tree row key is not of type oracle.jbo.domain.Key but an implementation of java.util.List that contains the row keys. The JUCtrlHierBinding class in the ADF Binding layer that represents the ADF tree binding at runtime provides a method named findNodeByKeyPath that allows you to get a handle to the JUCtrlHierNodeBinding instance that represents a tree node in the binding layer. CollectionModel model = (CollectionModel) your_af_tree_reference.getValue(); JUCtrlHierBinding treeBinding = (JUCtrlHierBinding ) model.getWrappedData(); JUCtrlHierNodeBinding treeDropNode = treeBinding.findNodeByKeyPath(dropRowKey); To disclose the tree node, you need to create a RowKeySet, which you do using the RowKeySetImpl class. Because the RowKeySet replaces any existing row key set in the tree, all other nodes are automatically closed. RowKeySetImpl rksImpl = new RowKeySetImpl(); //the first key to add is the node that received the drop //operation (departments).            rksImpl.add(dropRowKey);    Similar, from the tree binding, the root node can be obtained. The root node is the end of all parent node iteration and therefore important. JUCtrlHierNodeBinding rootNode = treeBinding.getRootNodeBinding(); The following code obtains a reference to the hierarchy of parent nodes until the root node is found. JUCtrlHierNodeBinding dropNodeParent = treeDropNode.getParent(); //walk up the tree to expand all parent nodes while(dropNodeParent != null && dropNodeParent != rootNode){    //add the node's keyPath (remember its a List) to the row key set    rksImpl.add(dropNodeParent.getKeyPath());      dropNodeParent = dropNodeParent.getParent(); } Next, you disclose the drop node immediate child nodes as otherwise all you see is the department node. Its not quite exactly "dinner for one", but the procedure is very similar to the one handling the parent node keys ArrayList<JUCtrlHierNodeBinding> childList = (ArrayList<JUCtrlHierNodeBinding>) treeDropNode.getChildren();                     for(JUCtrlHierNodeBinding nb : childList){   rksImpl.add(nb.getKeyPath()); } Next, the row key set is defined as the disclosed row keys on the tree so when you refresh (PPR) the tree, the new disclosed state shows tree.setDisclosedRowKeys(rksImpl); AdfFacesContext.getCurrentInstance().addPartialTarget(tree.getParent()); The refresh in my use case is on the tree parent component (a layout container), which usually shows the best effect for refreshing the tree component. 

    Read the article

  • Beyond Syntax Highlighting - What other code representations are possible today?

    - by Mathieu Hélie
    Despite GUI applications having been around for 30ish years, software is still written as lines of text instructions, for various valid reasons. But we've also found that manipulating these text instructions is mind-blowingly difficult unless we apply a layer of coloring on different words to represent their syntax, thus allowing us to quickly parse through these text files without having to read the whole words. But besides the Sublime Text minimap feature, I've yet to see any innovation in visual representation of code since colors came around on CRT monitors. I can think of one obviously essential representation that modern graphics technology allows: visual hierarchies for nested structures. If we make nested text slightly smaller than its outer context, and zoom on it when the cursor is focused on the line, then we will be able to browse huge files of nested statements very quickly. This becomes even more essential as languages based on closures and anonymous functions become filled with deep statements. Has anyone attempted to implement this in a text editor? Do you know of any otherwise useful improvements in representing code text graphically?

    Read the article

  • Problem with DirectX scene-graph

    - by Alex
    I'm trying to implement a basic scene graph in DirectX using C++. I am using a left child-right sibling binary tree to do this. I'm having trouble updating each node's world transformation relative to its parent (and its parent's parent etc.). I'm struggling to get it to work recursively, though I can get it to work like this: for(int i = 0; i < NUM_OBJECTS; i++) { // Initialize to identity matrix. D3DXMatrixIdentity(&mObject[i].toWorldXForm); int k = i; while( k != -1 ) { mObject[i].toWorldXForm *= mObject[k].toParentXForm; k = mObject[k].parent; } } toWorldXForm is the object's world transform and toParentXForm is the object's transform relative to the parent. I want to do this using a method within my object class (the code above is in my main class). This is what I've tried but it doesn't work (only works with nodes 1 generation away from the root) if (this->sibling != NULL) this->sibling->update(toParentXForm); D3DXMatrixIdentity(&toWorldXForm); this->toWorldXForm *= this->toParentXForm; this->toWorldXForm *= toParentXForm; toParentXForm *= this->toParentXForm; if (this->child != NULL) this->child->update(toParentXForm); Sorry if I've not been clear, please tell me if there's anything else you need to know. I've no doubt it's merely a silly mistake on my part, hopefully an outside view will be able to spot the problem.

    Read the article

  • How can I reconfigure the nvidia proprietary drivers from the command line (ssh)?

    - by Mathieu Pagé
    I have a linux HTPC (running XBMC) in my living room. This morning I ssh'ed into the machine and did upgrade it to 10.10. When it finaly resarted it says something about running in low quality graphics and eventually returned to a command line login prompt. I ssh'ed in again and did a sudo reboot now. When it came back on this time the image is rapidly scrolling from the top to the bottom of the screen. I guess the installed driver doesn't quite work with the S-Video port on which the TV is connected. previously it was working right with the nvidia proprietary drivers. How can I install thoses without using the GUI tool that comes with Ubuntu?

    Read the article

  • How do I query the gvfs metadata for a specific attribute?

    - by Mathieu Comandon
    A nice feature in evince is that when you close the program and later reopen the same pdf, it automatically jumps to the page you were reading. The problem I have is that I often read ebooks on several computers and I have to find were I was on the last computer I was reading the pdf. I think syncing these bookmarks in UbuntuOne would be a killer feature for people like me who read pdfs on different computers. By investigating a bit, I found where evince was storing this data, it's in the gvfs metadata and it can be accessed for a particular document by typing gvfs-ls -a "metadata::evince::page" myEbook.pdf Rather that querying a particular file, I'd like to query the whole metadata file (located in ~/.local/share/gvfs-metadata/home for the home directory) for any file where this particular attribute is set to some value. The biggest issue is that gvfs metadata and stored in binary files and we all know it's not easy to get something out of a binary file. So, do you know any way to query the gvfs metadata for some attribute?

    Read the article

  • How to write a blog for SEO purpose

    - by Mathieu Imbert
    I have a photo sharing website, which provides very little textual content. Users can add tags to photos and a description, but it creates a lot of duplicate content, because most of the descriptions will be 'wow', 'lol', ... I don't think I should rely on users to build my SEO. I think it would be a great idea to write a blog, and use it to describe the best photos, start contests, explain themes, in short: create original content that search engines will love. Our website's main URL is like www.domain.com, and our new blog is hosted on blog.domain.com. From a SEO perspective, is it a good idea to keep the blog separate from the main site? This has the advantage to leave the original site unchanged, but will it add any page rank to the www.domain.com? If the blog ranks well it will obviously pass some page rank to the original through links. What do you think is the best option from a SEO perspective? Include the blog in www.domain.com? Or leave it in blog.domain.com?

    Read the article

  • Disk drive for / not ready on boot after upgrade from 10.04 to 12.04

    - by Mathieu M-Gosselin
    After upgrading (using the Upgrade button from the update manager) from 10.04.4 to 12.04.1, I cannot boot anymore. Upon booting, I am greeted with the Ubuntu logo and the error "The disk drive for / is not ready yet or not present". I have the option to wait, to skip and to access a basic shell. Waiting overnight did nothing, skipping just gives me the same error for /tmp, /home, then for a UUID and finally it just goes to a black screen with a white "_" in the top left corner. My setup is a dual boot one with XP on a single hard drive, I use separate partitions for / and /home. Back in the day I installed 8.04 directly from the CD while leaving a partition for XP, which I installed after. This setup had never caused any such issues, even when upgrading from 8.04 to 10.04. I have done plenty of research regarding this issue, as many others seem to have had similar issues after doing the same upgrade as me. However, while for most what fixed the problem was running: apt-get -f install after remounting / in read-write, it didn't do it for me. I got dependency errors (see here), which I also investigated. I found https://bugs.launchpad.net/ubuntu/+source/python-defaults/+bug/990740 where most people say the solution that worked is (prior to running the above command) running: apt-get install -o APT::Immediate-Configure=false -f apt python-minimal but that also got me a lot of dependencies errors as output (see here), similar to #34 in the above thread. I also read that running: dpkg --configure -a could help, at first it wouldn't run because it had trouble parsing /var/lib/dpkg/status since there was an extra blank line in a package description (see https://bugs.launchpad.net/ubuntu/+source/dpkg/+bug/916799) but I removed it using vim (and then reran the command). It still gives me output that looks like an error, though. Here it is: http://paste.ubuntu.com/1338074/. I also tried re-running the above apt-get commands after that, to no avail. I'm running out of things to try in the hope of getting this fixed, your help would be very much appreciated! Thank you in advance.

    Read the article

  • Tree position terminology/naming

    - by wst
    This is a naming things question. I am processing trees (XML documents), and there are often special rules applied to nodes based on structure. It's been very difficult coming up with concise naming conventions for some cases, namely for nodes in the first position among their siblings, along with some recursive relationship: Given an arbitrary node, I want to describe its first child, and then that node's first child, and so on recursively. Given another arbitrary node, I want to describe its parent if the parent is first among its siblings, and that parent's parent if it's first, and so on recursively. Is there existing terminology to describe these tree positions? How would you name a variable or function that captures one of these cases so that it's intuitive to an unfamiliar developer trying to understand an algorithm?

    Read the article

  • Patterns for a tree of persistent data with multiple storage options?

    - by Robin Winslow
    I have a real-world problem which I'll try to abstract into an illustrative example. So imagine I have data objects in a tree, where parent objects can access children, and children can access parents: // Interfaces interface IParent<TChild> { List<TChild> Children; } interface IChild<TParent> { TParent Parent; } // Classes class Top : IParent<Middle> {} class Middle : IParent<Bottom>, IChild<Top> {} class Bottom : IChild<Middle> {} // Usage var top = new Top(); var middles = top.Children; // List<Middle> foreach (var middle in middles) { var bottoms = middle.Children; // List<Bottom> foreach (var bottom in bottoms) { var middle = bottom.Parent; // Access the parent var top = middle.Parent; // Access the grandparent } } All three data objects have properties that are persisted in two data stores (e.g. a database and a web service), and they need to reflect and synchronise with the stores. Some objects only request from the web service, some only write to it. Data Mapper My favourite pattern for data access is Data Mapper, because it completely separates the data objects themselves from the communication with the data store: class TopMapper { public Top FetchById(int id) { var top = new Top(DataStore.TopDataById(id)); top.Children = MiddleMapper.FetchForTop(Top); return Top; } } class MiddleMapper { public Middle FetchById(int id) { var middle = new Middle(DataStore.MiddleDataById(id)); middle.Parent = TopMapper.FetchForMiddle(middle); middle.Children = BottomMapper.FetchForMiddle(bottom); return middle; } } This way I can have one mapper per data store, and build the object from the mapper I want, and then save it back using the mapper I want. There is a circular reference here, but I guess that's not a problem because most languages can just store memory references to the objects, so there won't actually be infinite data. The problem with this is that every time I want to construct a new Top, Middle or Bottom, it needs to build the entire object tree within that object's Parent or Children property, with all the data store requests and memory usage that that entails. And in real life my tree is much bigger than the one represented here, so that's a problem. Requests in the object In this the objects request their Parents and Children themselves: class Middle { private List<Bottom> _children = null; // cache public List<Bottom> Children { get { _children = _children ?? BottomMapper.FetchForMiddle(this); return _children; } set { BottomMapper.UpdateForMiddle(this, value); _children = value; } } } I think this is an example of the repository pattern. Is that correct? This solution seems neat - the data only gets requested from the data store when you need it, and thereafter it's stored in the object if you want to request it again, avoiding a further request. However, I have two different data sources. There's a database, but there's also a web service, and I need to be able to create an object from the web service and save it back to the database and then request it again from the database and update the web service. This also makes me uneasy because the data objects themselves are no longer ignorant of the data source. We've introduced a new dependency, not to mention a circular dependency, making it harder to test. And the objects now mask their communication with the database. Other solutions Are there any other solutions which could take care of the multiple stores problem but also mean that I don't need to build / request all the data every time?

    Read the article

  • jQuery make child div visible on hover (on effective li element only, not parent!)

    - by Dennis
    I've already tried all of the existing posts related to this, but they doesn't work as I want it... The HTML: <ol class="sortable"> <li> <div> <a href="#">Start Page</a> <div class="li_options"> <a href="#"><img src="img/icons/small_add.png" /></a> <a href="#" onClick="[..]"><img src="img/icons/small_remove.png" /></a> </div> <div class="clear"></div> </div> <ol> <li> <div> <a href="#">Sub Seite</a> <div class="li_options"> <a href="#"><img src="img/icons/small_add.png" /></a> <a href="#" onClick="[..]"><img src="img/icons/small_remove.png" /></a> </div> <div class="clear"></div> </div> <ol> <li> <div> <a href="#">Sub Sub Seite</a> <div class="li_options"> <a href="#"><img src="img/icons/small_add.png" /></a> <a href="#" onClick="[..]"><img src="img/icons/small_remove.png" /></a> </div> <div class="clear"></div> </div> </li> </ol> </li> </ol> </li> <div class="clear"></div> This should look like this: Start Page Sub Page Sub Page I want the div.li_options which is set for every li element to be shown only on hovering element. I know, that the parent's li is also being "hovered" on hovering child elements, but I don't those "li_options" to be displayed. The best solution so far: $(document).ready(function() { $('.sortable li').mouseover(function() { $(this).children().children('.li_options').show(); }).mouseout(function() { $(this).children().children('.li_options').hide(); }); }); But with this, parents aren't being excluded... I don't know how to point on them, because there can be endless levels. Do you know how to get this working?

    Read the article

  • jQuery slide open and close menus. How to stop them going crazy? [closed]

    - by firefusion
    I want sub menu's of a verticle menu to expand and collapse when moused over. This is what i've got so far but it goes crazy if you do it to quick as all the animations run at once and on a delay. How can i make sure just one menu expands at a time. I've also set the current_page_item to be open but default and I don't want this to expand or collaspe. <ul> <li class="current_page_item"><a href="#">Parent Item</a> <ul class="children"> <li class="page_item"><a href="#">Child page</a></li> <li class="page_item"><a href="#">Child page</a></li> <li class="page_item"><a href="#">Child page</a></li> <li class="page_item"><a href="#">Child page</a></li> </ul> </li> <li class="page_item"><a href="#">Parent Item</a> <ul class="children"> <li class="page_item"><a href="#">Child page</a></li> <li class="page_item"><a href="#">Child page</a></li> </ul> </li> <li class="page_item"><a href="#">Parent Item</a> <ul class="children"> <li class="page_item"><a href="#">Child page</a></li> <li class="page_item"><a href="#">Child page</a></li> </ul> </li> <li class="page_item"><a href="#">Parent Item</a></li> <li class="page_item"><a href="#">Parent Item</a></li> </ul> jQuery('ul.children').hide(); jQuery('li.current_page_item ul.children').show(); jQuery('li.current_page_item').parent().show(); jQuery("li.page_item").hover(function() { jQuery(this).find('ul.children').delay(300).slideDown('slow'); }, function() { jQuery(this).find('ul.children').delay(300).slideUp('slow'); });

    Read the article

  • How can I filter images and use filesystemview icons in my jtree?

    - by HoLeX
    First of all sorry about my english. So, i have some problems with my JTree because i want to filter specific types of images and also i want to use icons of FileSystemView class. Can you help me? I will appreciate so much. Here is my code: import java.awt.BorderLayout; import java.io.File; import java.util.Iterator; import java.util.Vector; import javax.swing.JPanel; import javax.swing.JTree; import javax.swing.event.TreeModelEvent; import javax.swing.event.TreeModelListener; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; import javax.swing.tree.TreeModel; import javax.swing.tree.TreePath; public class ArbolDirectorio extends JPanel { private JTree fileTree; private FileSystemModel fileSystemModel; public ArbolDirectorio(String directory) { this.setLayout(new BorderLayout()); this.fileSystemModel = new FileSystemModel(new File(directory)); this.fileTree = new JTree(fileSystemModel); this.fileTree.setEditable(true); this.fileTree.addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent event) { File file = (File) fileTree.getLastSelectedPathComponent(); System.out.println(getFileDetails(file)); } }); this.add(fileTree, BorderLayout.CENTER); } private String getFileDetails(File file) { if (file == null) { return ""; } StringBuffer buffer = new StringBuffer(); buffer.append("Name: " + file.getName() + "\n"); buffer.append("Path: " + file.getPath() + "\n"); return buffer.toString(); } } class FileSystemModel implements TreeModel { private File root; private Vector listeners = new Vector(); public FileSystemModel(File rootDirectory) { root = rootDirectory; } @Override public Object getRoot() { return root; } @Override public Object getChild(Object parent, int index) { File directory = (File) parent; String[] children = directory.list(); return new TreeFile(directory, children[index]); } @Override public int getChildCount(Object parent) { File file = (File) parent; if (file.isDirectory()) { String[] fileList = file.list(); if (fileList != null) { return file.list().length; } } return 0; } @Override public boolean isLeaf(Object node) { File file = (File) node; return file.isFile(); } @Override public int getIndexOfChild(Object parent, Object child) { File directory = (File) parent; File file = (File) child; String[] children = directory.list(); for (int i = 0; i < children.length; i++) { if (file.getName().equals(children[i])) { return i; } } return -1; } @Override public void valueForPathChanged(TreePath path, Object value) { File oldFile = (File) path.getLastPathComponent(); String fileParentPath = oldFile.getParent(); String newFileName = (String) value; File targetFile = new File(fileParentPath, newFileName); oldFile.renameTo(targetFile); File parent = new File(fileParentPath); int[] changedChildrenIndices = { getIndexOfChild(parent, targetFile) }; Object[] changedChildren = { targetFile }; fireTreeNodesChanged(path.getParentPath(), changedChildrenIndices, changedChildren); } private void fireTreeNodesChanged(TreePath parentPath, int[] indices, Object[] children) { TreeModelEvent event = new TreeModelEvent(this, parentPath, indices, children); Iterator iterator = listeners.iterator(); TreeModelListener listener = null; while (iterator.hasNext()) { listener = (TreeModelListener) iterator.next(); listener.treeNodesChanged(event); } } @Override public void addTreeModelListener(TreeModelListener listener) { listeners.add(listener); } @Override public void removeTreeModelListener(TreeModelListener listener) { listeners.remove(listener); } private class TreeFile extends File { public TreeFile(File parent, String child) { super(parent, child); } @Override public String toString() { return getName(); } } }

    Read the article

  • Problem with GCC calling static templates functions in templated parent class.

    - by Adisak
    I have some code that compiles and runs on MSVC++ but will not compile on GCC. I have made a test snippet that follows. My goal was to move the static method from BFSMask to BFSMaskSized. Can someone explain what is going on with the errors (esp. the weird 'operator<' error)? Thank you. In the case of both #defines are 0, then the code compiles on GCC. #define DOESNT_COMPILE_WITH_GCC 0 #define FUNCTION_IN_PARENT 0 I get errors if I change either #define to 1. Here are the errors I see. #define DOESNT_COMPILE_WITH_GCC 0 #define FUNCTION_IN_PARENT 1 Test.cpp: In static member function 'static typename Snapper::BFSMask<T>::T_Parent::T_SINT Snapper::BFSMask<T>::Create_NEZ(TCMP)': Test.cpp(492): error: 'CreateMaskFromHighBitSized' was not declared in this scope #define DOESNT_COMPILE_WITH_GCC 1 #define FUNCTION_IN_PARENT 0 Test.cpp: In static member function 'static typename Snapper::BFSMask<T>::T_Parent::T_SINT Snapper::BFSMask<T>::Create_NEZ(TCMP) [with TCMP = int, T = int]': Test.cpp(500): instantiated from 'TVAL Snapper::BFWrappedInc(TVAL, TVAL, TVAL) [with TVAL = int]' Test.cpp(508): instantiated from here Test.cpp(490): error: invalid operands of types '<unresolved overloaded function type>' and 'unsigned int' to binary 'operator<' #define DOESNT_COMPILE_WITH_GCC 1 #define FUNCTION_IN_PARENT 1 Test.cpp: In static member function 'static typename Snapper::BFSMask<T>::T_Parent::T_SINT Snapper::BFSMask<T>::Create_NEZ(TCMP) [with TCMP = int, T = int]': Test.cpp(500): instantiated from 'TVAL Snapper::BFWrappedInc(TVAL, TVAL, TVAL) [with TVAL = int]' Test.cpp(508): instantiated from here Test.cpp(490): error: invalid operands of types '<unresolved overloaded function type>' and 'unsigned int' to binary 'operator<' Here is the code namespace Snapper { #define DOESNT_COMPILE_WITH_GCC 0 #define FUNCTION_IN_PARENT 0 // MASK TYPES // NEZ - Not Equal to Zero #define BFSMASK_NEZ(A) ( ( A ) | ( 0 - A ) ) #define BFSELECT_MASK(MASK,VTRUE,VFALSE) ( ((MASK)&(VTRUE)) | ((~(MASK))&(VFALSE)) ) template<typename TVAL> TVAL BFSelect_MASK(TVAL MASK,TVAL VTRUE,TVAL VFALSE) { return(BFSELECT_MASK(MASK,VTRUE,VFALSE)); } //----------------------------------------------------------------------------- // Branch Free Helpers template<int BYTESIZE> struct BFSMaskBase {}; template<> struct BFSMaskBase<2> { typedef UINT16 T_UINT; typedef SINT16 T_SINT; }; template<> struct BFSMaskBase<4> { typedef UINT32 T_UINT; typedef SINT32 T_SINT; }; template<int BYTESIZE> struct BFSMaskSized : public BFSMaskBase<BYTESIZE> { static const int SizeBytes = BYTESIZE; static const int SizeBits = SizeBytes*8; static const int MaskShift = SizeBits-1; typedef typename BFSMaskBase<BYTESIZE>::T_UINT T_UINT; typedef typename BFSMaskBase<BYTESIZE>::T_SINT T_SINT; #if FUNCTION_IN_PARENT template<int N> static T_SINT CreateMaskFromHighBitSized(typename BFSMaskBase<N>::T_SINT inmask); #endif }; template<typename T> struct BFSMask : public BFSMaskSized<sizeof(T)> { // BFSMask = -1 (all bits set) typedef BFSMask<T> T_This; // "Import" the Parent Class typedef BFSMaskSized<sizeof(T)> T_Parent; typedef typename T_Parent::T_SINT T_SINT; #if FUNCTION_IN_PARENT typedef T_Parent T_MaskGen; #else typedef T_This T_MaskGen; template<int N> static T_SINT CreateMaskFromHighBitSized(typename BFSMaskSized<N>::T_SINT inmask); #endif template<typename TCMP> static T_SINT Create_NEZ(TCMP A) { //ReDefineType(const typename BFSMask<TCMP>::T_SINT,SA,A); //const typename BFSMask<TCMP>::T_SINT cmpmask = BFSMASK_NEZ(SA); const typename BFSMask<TCMP>::T_SINT cmpmask = BFSMASK_NEZ(A); #if DOESNT_COMPILE_WITH_GCC return(T_MaskGen::CreateMaskFromHighBitSized<sizeof(TCMP)>(cmpmask)); #else return(CreateMaskFromHighBitSized<sizeof(TCMP)>(cmpmask)); #endif } }; template<typename TVAL> TVAL BFWrappedInc(TVAL x,TVAL minval,TVAL maxval) { const TVAL diff = maxval-x; const TVAL mask = BFSMask<TVAL>::Create_NEZ(diff); const TVAL incx = x + 1; return(BFSelect_MASK(mask,incx,minval)); } SINT32 currentsnap = 0; SINT32 SetSnapshot() { currentsnap=BFWrappedInc<SINT32>(currentsnap,0,20); return(currentsnap); } }

    Read the article

  • 'click' observer in Prototype

    - by Tom
    I have a page which contains several divs (each with a unique ID and the same class, 'parent'). Underneath each "parent" div, is a div with class "child" and unique ID name -child. This DIV is upon page load empty. Whenever you click on a parent DIV, the following code is executed. $$('div.parent').each(function(s){ $(s).observe('click', function(event){ event.stop(); var filer = $(s).readAttribute('filer'); var currentElement = $(s).id; var childElement = currentElement + '-children'; new Ajax.Updater ({success: childElement}, root + '/filers/interfacechildren', { parameters: {parentId: currentElement, filer: filer} }); }); }); Of course, it's possible that a child node is again a parent ont its own. The response looks like this (Smarty with Zend Framework): {foreach from=$ifaces item=interface} <div id="{$interface->name}" filer="{$interface->system_id}" class="parent">{$interface->name}</div> <div id="{$interface->name}-children" class="child"></div> {/foreach} Whenever I click on a "parent" div that is loaded inside a child, nothing happens :( Any suggestions / fixes how to fix this?

    Read the article

  • Flex 3 : UIComponent.addChild issue

    - by Frank
    Hello SOers, I've run into a nice problem with the UIComponent.addChild(...) function. First of all, I'm using ESRI Api for Flex. In this API you find a class called Graphic that inherits UIComponent. Basically, I'm trying to add, as a child, a Graphic 'g' to another graphic 'parent'. So that when you delete the 'parent' graphic the 'g' graphic deletes as well. private function writeMeasurements(parent:Graphic):void { var g:Graphic; if(parent.geometry.extent != null) g = new Graphic(parent.geometry.extent.center); else g = new Graphic(parent.geometry); g.initialize(); g.name = UIDUtil.createUID(); g.symbol = txtSym; graphicsLayer.add(g); parent.addChild(g); } graphicsLayer class This code actually runs pretty fine. The problem is after... it's like if the addChild function was asynchronious. This is the error I get : TypeError: Error #1009: Il est impossible d'accéder à la propriété ou à la méthode d'une référence d'objet nul. at com.esri.ags::Graphic/updateDisplayList()[C:\checkout\flex_api\api\src\com\esri\ags\Graphic.as:346] at mx.core::UIComponent/validateDisplayList() at mx.managers::LayoutManager/validateDisplayList() at mx.managers::LayoutManager/doPhasedInstantiation() at Function/http://adobe.com/AS3/2006/builtin::apply() at mx.core::UIComponent/callLaterDispatcher2() at mx.core::UIComponent/callLaterDispatcher() I know this is a very specific question, but I think you guys are the BEST! Thanks.

    Read the article

  • MySQL nested set hierarchy with foreign table

    - by Björn
    Hi! I'm using a nested set in a MySQL table to describe a hierarchy of categories, and an additional table describing products. Category table; id name left right Products table; id categoryId name How can I retrieve the full path, containing all parent categories, of a product? I.e.: RootCategory > SubCategory 1 > SubCategory 2 > ... > SubCategory n > Product Say for example that I want to list all products from SubCategory1 and it's sub categories, and with each given Product I want the full tree path to that product - is this possible? This is as far as I've got - but the structure is not quite right... select parent.`name` as name, parent.`id` as id, group_concat(parent.`name` separator '/') as path from categories as node, categories as parent, (select inode.`id` as id, inode.`name` as name from categories as inode, categories as iparent where inode.`lft` between iparent.`lft` and iparent.`rgt` and iparent.`id`=4 /* The category from which to list products */ order by inode.`lft`) as sub where node.`lft` between parent.`lft` and parent.`rgt` and node.`id`=sub.`id` group by sub.`id` order by node.`lft`

    Read the article

  • How to generate a key for a group entity?

    - by user246114
    Hi, I'm trying to make a group entity. Something like: class User { } class UserColor { } ... Key key = new KeyFactory.Builder( User.class.getSimpleName(), username). .addChild(UserColor.class.getSimpleName(), ???).getKey(); I know the unique username up-front to use for the key of the User object. But I just want app engine to generate a random unique value for the key value of the UserColor instance. I think this is described here, but I don't understand their wording: http://code.google.com/appengine/docs/java/datastore/transactions.html To create an object with a system-generated numeric ID and an entity group parent, you must use an entity group parent key field (such as customerKey, above). Assign the key of the parent to the parent key field, then leave the object's key field set to null. When the object is saved, the datastore populates the key field with the complete key, including the entity group parent. and this is their example: @Persistent @Extension(vendorName="datanucleus", key="gae.parent-pk", value="true") private Key customerKey; but I don't understand - should UserColor look like this then?: class UserColor { @Persistent @Extension(vendorName="datanucleus", key="gae.parent-pk", value="true") private Key mKeyParent; @Primary private Key mKey; // leave null } ... Key keyParent = new KeyFactory.Builder( User.class.getSimpleName(), username); UserColor uc = new UserColor(); uc.setKeyParent(keyParent); pm.makePersistent(uc); // now generated for me automatically? is that correct? Using this method, I should be able to use a User and a UserColor object in a transaction together, right? Thanks

    Read the article

  • Why can't I pass an argument to create this window using wxpython?

    - by somefreakingguy
    I am trying to learn how to make a GUI in python! Following an online tutorial, I found that the following code 'works' in creating an empty window: import wx from sys import argv class bucky(wx.Frame): def __init__(self, parent, id): wx.Frame.__init__(self, parent, id, 'Frame aka window', size=(300, 200)) if __name__=='__main__': app=wx.PySimpleApp() frame=bucky(parent=None,id=-1) frame.Show() app.MainLoop() That gives me a window, which is great. However, what if I want to get an argument passed onto the program to determine the window size? I thought something like this ought to do the trick: import wx from sys import argv script, x, y = argv class mywindow(wx.Frame): def __init__(self, parent, id): wx.Frame.__init__(self, parent, id, 'Frame aka window', size=(x, y)) if __name__=='__main__': app=wx.PySimpleApp() frame=mywindow(parent=None,id=-1) frame.Show() app.MainLoop() But, alas, that does not work! Nor does the raw_input() function pass on the value. I keep getting the following error: C:/Python26/pythonw.exe -u "C:/Documents and Settings/Owner/Desktop/wz.py" File "C:/Documents and Settings/Owner/Desktop/wz.py", line 8 wx.Frame.__init__(self, parent, id, 'Frame aka window', size=(x y)) ^ SyntaxError: invalid syntax Thanks for the help!

    Read the article

  • Avoiding a fork()/SIGCHLD race condition

    - by larry
    Please consider the following fork()/SIGCHLD pseudo-code. // main program excerpt for (;;) { if ( is_time_to_make_babies ) { pid = fork(); if (pid == -1) { /* fail */ } else if (pid == 0) { /* child stuff */ print "child started" exit } else { /* parent stuff */ print "parent forked new child ", pid children.add(pid); } } } // SIGCHLD handler sigchld_handler(signo) { while ( (pid = wait(status, WNOHANG)) > 0 ) { print "parent caught SIGCHLD from ", pid children.remove(pid); } } In the above example there's a race-condition. It's possible for "/* child stuff */" to finish before "/* parent stuff */" starts which can result in a child's pid being added to the list of children after it's exited, and never being removed. When the time comes for the app to close down, the parent will wait endlessly for the already-finished child to finish. One solution I can think of to counter this is to have two lists: started_children and finished_children. I'd add to started_children in the same place I'm adding to children now. But in the signal handler, instead of removing from children I'd add to finished_children. When the app closes down, the parent can simply wait until the difference between started_children and finished_children is zero. Another possible solution I can think of is using shared-memory, e.g. share the parent's list of children and let the children .add and .remove themselves? But I don't know too much about this. EDIT: Another possible solution, which was the first thing that came to mind, is to simply add a sleep(1) at the start of /* child stuff */ but that smells funny to me, which is why I left it out. I'm also not even sure it's a 100% fix. So, how would you correct this race-condition? And if there's a well-established recommended pattern for this, please let me know! Thanks.

    Read the article

  • how to get access to private members of nested class?

    - by macias
    Background: I have enclosed (parent) class E with nested class N with several instances of N in E. In the enclosed (parent) class I am doing some calculations and I am setting the values for each instance of nested class. Something like this: n1.field1 = ...; n1.field2 = ...; n1.field3 = ...; n2.field1 = ...; ... It is one big eval method (in parent class). My intention is -- since all calculations are in parent class (they cannot be done per nested instance because it would make code more complicated) -- make the setters only available to parent class and getters public. And now there is a problem: when I make the setters private, parent class cannot acces them when I make them public, everybody can change the values and C# does not have friend concept I cannot pass values in constructor because lazy evaluation mechanism is used (so the instances have to be created when referencing them -- I create all objects and the calculation is triggered on demand) I am stuck -- how to do this (limit access up to parent class, no more, no less)? I suspect I'll get answer-question first -- "but why you don't split the evaluation per each field" -- so I answer this by example: how do you calculate min and max value of a collection? In a fast way? The answer is -- in one pass. This is why I have one eval function which does calculations and sets all fields at once.

    Read the article

  • Can I get an XPathNodeIterator directly from an XPath?

    - by Val
    I hope I'm just missing something obvious. I have a number of repeating nodes in an XML document: <root> <parent> <child/> <child/> </parent> </root> I need to examine the contents of each of the <child> elements in turn, so I need an XPathNodeIterator containing the nodeset of all the <child> nodes. If I have an XPath that would select the child nodes, e.g. /root/parent/child, is there any way to feed that directly to a new XPathNodeIterator? Everything I see in the docs and examples indicates I have to first get an XPathNavigator to the <parent>, then Select the child nodes, like: XPathNavigator nav = datasource.CreateNavigator().SelectSingleNode( "/root/parent" ); XPathNodeIterator it = nav.Select( "./child" ); foreach ( child in it ) { /* do something */ } I was hoping to skip the XPathNavigator, and intialize the XPathNodeIterator with XPath to the child nodes directly, something like: XpathNodeIterator it = new XpathNodeIterator("/root/parent/child"); foreach ( child in it ) { /* do something */ } Possible? The benefit is not only saving a line of code, but I can use a single XPath expression, rather than splitting the path to the <child> nodes in two, first to get the parent element, then to select its children.

    Read the article

  • problem in creating a php tree menu

    - by Mac Taylor
    hi mates im writing a tree menu for my categories in php and i wonder how can i code it correctly ! this is my table in database " |----topicid------topicname--------parent | |---- 1 ------ News -------- 0 | |---- 2 ------ sport -------- 1 | |---- 3 ------ games -------- 1 | |---- 4 ------ PES -------- 3 | so now for showing it like a tree i did try but not worked : $result = mysql_query("SELECT * FROM Topics ORDER BY topicid"); while ($row = mysql_fetchrow($result)) { $id = intval($row['topicid']); $title = filter($row['topicname'], "nohtml"); $parent = $row['parent'] ; if ($parent==0) { $menu_item .= "<li><span class='folder'><a title = \"$alt\" href=\"modules.php?name=News&amp;new_topic=$id\">$title</a></span></li>"; }else { $result = mysql_query("SELECT * FROM ".$prefix."_Topics where parent='$id' ORDER BY topicid"); while ($row = mysql_fetchrow($result)) { $id = intval($row['topicid']); $title = filter($row['topicname'], "nohtml"); $parent = $row['parent'] ; $menu_item .= " <ul><li><span class='file'><a title = \"$alt\" href=\"modules.php?name=News&amp;new_topic=$id\">$title</a></span></li></ul>"; } } i dont know how to solve this

    Read the article

  • Linq - reuse expression on child property

    - by user175528
    Not sure if what I am trying is possible or not, but I'd like to reuse a linq expression on an objects parent property. With the given classes: class Parent { int Id { get; set; } IList<Child> Children { get; set; } string Name { get; set; } } class Child{ int Id { get; set; } Parent Dad { get; set; } string Name { get; set; } } If i then have a helper Expression<Func<Parent,bool> ParentQuery() { Expression<Func<Parent,bool> q = p => p.Name=="foo"; } I then want to use this when querying data out for a child, along the lines of: using(var context=new Entities.Context) { var data=context.Child.Where(c => c.Name=="bar" && c.Dad.Where(ParentQuery)); } I know I can do that on child collections: using(var context=new Entities.Context) { var data=context.Parent.Where(p => p.Name=="foo" && p.Childen.Where(childQuery)); } but cant see any way to do this on a property that isnt a collection. This is just a simplified example, actually the ParentQuery will be more complex and I want to avoid having this repeated in multiple places as rather than just having 2 layers I'll have closer to 5 or 6, but all of them will need to reference the parent query to ensure security.

    Read the article

< Previous Page | 40 41 42 43 44 45 46 47 48 49 50 51  | Next Page >