Search Results

Search found 710 results on 29 pages for 'containers'.

Page 3/29 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Are IoC containers about configuration files?

    - by Jader Dias
    Recently I developed a performance tester console application, with no UI, with the help of a IoC containter (Castle-Windsor-Microkernel). This library enabled me to let the user choose which test(s) to run, simply by changing the configuration file. Have I realized what IoC containers are about? I'm not sure. Even Joel said here on SO that IoC are difficult to understand. From my example, what do you conclude? Am I using IoC container for exactly what they were designed for? Or I am just using one of its secondary features?

    Read the article

  • Business Objects - Containers or functional?

    - by Walter
    Where I work, we've gone back and forth on this subject a number of times and are looking for a sanity check. Here's the question: Should Business Objects be data containers (more like DTOs) or should they also contain logic that can perform some functionality on that object. Example - Take a customer object, it probably contains some common properties (Name, Id, etc), should that customer object also include functions (Save, Calc, etc.)? One line of reasoning says separate the object from the functionality (single responsibility principal) and put the functionality in a Business Logic layer or object. The other line of reasoning says, no, if I have a customer object I just want to call Customer.Save and be done with it. Why do I need to know about how to save a customer if I'm consuming the object? Our last two projects have had the objects separated from the functionality, but the debate has been raised again on a new project. Which makes more sense? EDIT These results are very similar to our debates. One vote to one side or another completely changes the direction. Does anyone else want to add their 2 cents? EDIT Eventhough the answer sampling is small, it appears that the majority believe that functionality in a business object is acceptable as long as it is simple but persistence is best placed in a separate class/layer. We'll give this a try. Thanks for everyone's input...

    Read the article

  • Generic factory of generic containers

    - by Feuermurmel
    I have a generic abstract class Factory<T> with a method createBoxedInstance() which returns instances of T created by implementations of createInstance() wrapped in the generic container Box<T>. abstract class Factory<T> { abstract T createInstance(); public final Box<T> createBoxedInstance() { return new Box<T>(createInstance()); } public final class Box<T> { public final T content; public Box(T content) { this.content = content; } } } At some points I need a container of type Box<S> where S is an ancestor of T. Is it possible to make createBoxedInstance() itself generic so that it will return instances of Box<S> where S is chosen by the caller? Sadly, defining the function as follows does not work as a type parameter cannot be declared using the super keyword, only used. public final <S super T> Box<S> createBoxedInstance() { return new Box<S>(createInstance()); } The only alternative I see, is to make all places that need an instance of Box<S> accept Box<? extends S> which makes the container's content member assignable to S. Is there some way around this without re-boxing the instances of T into containers of type Box<S>? (I know I could just cast the Box<T> to a Box<S> but I would feel very, very guilty.)

    Read the article

  • Improving Manageability of Virtual Environments

    - by Jeff Victor
    Boot Environments for Solaris 10 Branded Zones Until recently, Solaris 10 Branded Zones on Solaris 11 suffered one notable regression: Live Upgrade did not work. The individual packaging and patching tools work correctly, but the ability to upgrade Solaris while the production workload continued running did not exist. A recent Solaris 11 SRU (Solaris 11.1 SRU 6.4) restored most of that functionality, although with a slightly different concept, different commands, and without all of the feature details. This new method gives you the ability to create and manage multiple boot environments (BEs) for a Solaris 10 Branded Zone, and modify the active or any inactive BE, and to do so while the production workload continues to run. Background In case you are new to Solaris: Solaris includes a set of features that enables you to create a bootable Solaris image, called a Boot Environment (BE). This newly created image can be modified while the original BE is still running your workload(s). There are many benefits, including improved uptime and the ability to reboot into (or downgrade to) an older BE if a newer one has a problem. In Solaris 10 this set of features was named Live Upgrade. Solaris 11 applies the same basic concepts to the new packaging system (IPS) but there isn't a specific name for the feature set. The features are simply part of IPS. Solaris 11 Boot Environments are not discussed in this blog entry. Although a Solaris 10 system can have multiple BEs, until recently a Solaris 10 Branded Zone (BZ) in a Solaris 11 system did not have this ability. This limitation was addressed recently, and that enhancement is the subject of this blog entry. This new implementation uses two concepts. The first is the use of a ZFS clone for each BE. This makes it very easy to create a BE, or many BEs. This is a distinct advantage over the Live Upgrade feature set in Solaris 10, which had a practical limitation of two BEs on a system, when using UFS. The second new concept is a very simple mechanism to indicate the BE that should be booted: a ZFS property. The new ZFS property is named com.oracle.zones.solaris10:activebe (isn't that creative? ). It's important to note that the property is inherited from the original BE's file system to any BEs you create. In other words, all BEs in one zone have the same value for that property. When the (Solaris 11) global zone boots the Solaris 10 BZ, it boots the BE that has the name that is stored in the activebe property. Here is a quick summary of the actions you can use to manage these BEs: To create a BE: Create a ZFS clone of the zone's root dataset To activate a BE: Set the ZFS property of the root dataset to indicate the BE To add a package or patch to an inactive BE: Mount the inactive BE Add packages or patches to it Unmount the inactive BE To list the available BEs: Use the "zfs list" command. To destroy a BE: Use the "zfs destroy" command. Preparation Before you can use the new features, you will need a Solaris 10 BZ on a Solaris 11 system. You can use these three steps - on a real Solaris 11.1 server or in a VirtualBox guest running Solaris 11.1 - to create a Solaris 10 BZ. The Solaris 11.1 environment must be at SRU 6.4 or newer. Create a flash archive on the Solaris 10 system s10# flarcreate -n s10-system /net/zones/archives/s10-system.flar Configure the Solaris 10 BZ on the Solaris 11 system s11# zonecfg -z s10z Use 'create' to begin configuring a new zone. zonecfg:s10z create -t SYSsolaris10 zonecfg:s10z set zonepath=/zones/s10z zonecfg:s10z exit s11# zoneadm list -cv ID NAME STATUS PATH BRAND IP 0 global running / solaris shared - s10z configured /zones/s10z solaris10 excl Install the zone from the flash archive s11# zoneadm -z s10z install -a /net/zones/archives/s10-system.flar -p You can find more information about the migration of Solaris 10 environments to Solaris 10 Branded Zones in the documentation. The rest of this blog entry demonstrates the commands you can use to accomplish the aforementioned actions related to BEs. New features in action Note that the demonstration of the commands occurs in the Solaris 10 BZ, as indicated by the shell prompt "s10z# ". Many of these commands can be performed in the global zone instead, if you prefer. If you perform them in the global zone, you must change the ZFS file system names. Create The only complicated action is the creation of a BE. In the Solaris 10 BZ, create a new "boot environment" - a ZFS clone. You can assign any name to the final portion of the clone's name, as long as it meets the requirements for a ZFS file system name. s10z# zfs snapshot rpool/ROOT/zbe-0@snap s10z# zfs clone -o mountpoint=/ -o canmount=noauto rpool/ROOT/zbe-0@snap rpool/ROOT/newBE cannot mount 'rpool/ROOT/newBE' on '/': directory is not empty filesystem successfully created, but not mounted You can safely ignore that message: we already know that / is not empty! We have merely told ZFS that the default mountpoint for the clone is the root directory. List the available BEs and active BE Because each BE is represented by a clone of the rpool/ROOT dataset, listing the BEs is as simple as listing the clones. s10z# zfs list -r rpool/ROOT NAME USED AVAIL REFER MOUNTPOINT rpool/ROOT 3.55G 42.9G 31K legacy rpool/ROOT/zbe-0 1K 42.9G 3.55G / rpool/ROOT/newBE 3.55G 42.9G 3.55G / The output shows that two BEs exist. Their names are "zbe-0" and "newBE". You can tell Solaris that one particular BE should be used when the zone next boots by using a ZFS property. Its name is com.oracle.zones.solaris10:activebe. The value of that property is the name of the clone that contains the BE that should be booted. s10z# zfs get com.oracle.zones.solaris10:activebe rpool/ROOT NAME PROPERTY VALUE SOURCE rpool/ROOT com.oracle.zones.solaris10:activebe zbe-0 local Change the active BE When you want to change the BE that will be booted next time, you can just change the activebe property on the rpool/ROOT dataset. s10z# zfs get com.oracle.zones.solaris10:activebe rpool/ROOT NAME PROPERTY VALUE SOURCE rpool/ROOT com.oracle.zones.solaris10:activebe zbe-0 local s10z# zfs set com.oracle.zones.solaris10:activebe=newBE rpool/ROOT s10z# zfs get com.oracle.zones.solaris10:activebe rpool/ROOT NAME PROPERTY VALUE SOURCE rpool/ROOT com.oracle.zones.solaris10:activebe newBE local s10z# shutdown -y -g0 -i6 After the zone has rebooted: s10z# zfs get com.oracle.zones.solaris10:activebe rpool/ROOT rpool/ROOT com.oracle.zones.solaris10:activebe newBE local s10z# zfs mount rpool/ROOT/newBE / rpool/export /export rpool/export/home /export/home rpool /rpool Mount the original BE to see that it's still there. s10z# zfs mount -o mountpoint=/mnt rpool/ROOT/zbe-0 s10z# ls /mnt Desktop export platform Documents export.backup.20130607T214951Z proc S10Flar home rpool TT_DB kernel sbin bin lib system boot lost+found tmp cdrom mnt usr dev net var etc opt Patch an inactive BE At this point, you can modify the original BE. If you would prefer to modify the new BE, you can restore the original value to the activebe property and reboot, and then mount the new BE to /mnt (or another empty directory) and modify it. Let's mount the original BE so we can modify it. (The first command is only needed if you haven't already mounted that BE.) s10z# zfs mount -o mountpoint=/mnt rpool/ROOT/zbe-0 s10z# patchadd -R /mnt -M /var/sadm/spool 104945-02 Note that the typical usage will be: Create a BE Mount the new (inactive) BE Use the package and patch tools to update the new BE Unmount the new BE Reboot Delete an inactive BE ZFS clones are children of their parent file systems. In order to destroy the parent, you must first "promote" the child. This reverses the parent-child relationship. (For more information on this, see the documentation.) The original rpool/ROOT file system is the parent of the clones that you create as BEs. In order to destroy an earlier BE that is that parent of other BEs, you must first promote one of the child BEs to be the ZFS parent. Only then can you destroy the original BE. Fortunately, this is easier to do than to explain: s10z# zfs promote rpool/ROOT/newBE s10z# zfs destroy rpool/ROOT/zbe-0 s10z# zfs list -r rpool/ROOT NAME USED AVAIL REFER MOUNTPOINT rpool/ROOT 3.56G 269G 31K legacy rpool/ROOT/newBE 3.56G 269G 3.55G / Documentation This feature is so new, it is not yet described in the Solaris 11 documentation. However, MOS note 1558773.1 offers some details. Conclusion With this new feature, you can add and patch packages to boot environments of a Solaris 10 Branded Zone. This ability improves the manageability of these zones, and makes their use more practical. It also means that you can use the existing P2V tools with earlier Solaris 10 updates, and modify the environments after they become Solaris 10 Branded Zones.

    Read the article

  • it is a good approach to implement dependency injection in a desktop app?

    - by luis_laurent
    Well, the thing is that I am just about to create a Desktop App (with .NET windows forms) And now I just wonder if it would be really a wise choise to use any IoC (StructureMap,Ninject,Spring .Net), I have used them before for Asp.Net web applications but what makes me doubt now is the fact that working with windows forms my business entities will persist when I navigate through tabs and unlike than web forms or mvc apps where it would be necesary to inject my business entity for every new request that is performed, I mean this because of the Asp.Net page life cycle where is performed the initialization and controls instantiation. Maybe I am misunderstanding the point of using an IoC, so please tell me what do you think would be a better choise?

    Read the article

  • How to generate thumbnails for less common video containers (mkv, ogm, mp4, flv, rmvb and mov) in wi

    - by fluxtendu
    So how to generate thumbnails for these containers? I know that the install of "DivX Plus Tech Preview: MKV on Windows 7" does it for MKV. But I think that only some registry changes are really necessary and I want it for other containers. If it's possible to avoiding the install of (always bloated) codecs packs it would be nice... Maybe only installing ffdshow or essential and separated codecs. (some time ago I have try reg files for vista without success...) Update: I have installed Win7codecs & tweaked a little its settings and I got almost everything I want. (I have also re-installed the relevant part of the divx plus tech preview to get something else than an all black preview for MKV) Issues that I still want to resolve: Find a cleaner & lighter method Almost all my rmvb and mov files got an all black preview (installing real media/quick time alternative doesn't help, is it the same with the officials?) With almost all containers (avi, mkv, ogm, mpg), I have (few) random files that don't get the preview. I could play them in WMP or another player and don't have found a pattern in the codecs used. All wmv, flv and mp4 have previews but I have less files in these containers. (I clear my thumbnails cache to test them) More generally I would like to understand how windows handle the containers & codecs to generate the previews. And a software that let me choose arbitrarily the pictures previewed would be convenient too

    Read the article

  • Wpf nesting containers

    - by dortzur
    On a window control, my main container is a grid. My grid has 2 rows, one row definition is 50*, and the other is 250*. Now i want to add a right sidebar, lets say with a StackPanel. I would like to have a ListBox inside the StackPanel that aligns with the 50* grid row, so as the window height gets bigger, the ListBox size will also get bigger. My question is whether i can achieve this behavior while the ListBox is inside the StackPanel (which is nested inside the grid) or must the ListBox be placed directly inside the grid?

    Read the article

  • DDD and IOC Containers

    - by MegaByte
    Hi Im fairly new with DDD and Im trying to use IOC in order to loosen up my tightly coupled layers :) My C# web application consists of a UI, domain and persistence layer. My persistence layer references my domain layer and contains my concrete repository implementations and nhibernate mappings. Currently my UI references my domain layer. My question : How do I use an IOC container to inject my concrete classes, in my persistence layer, into my domain layer? Does this meen that my UI should also reference my persistence layer?

    Read the article

  • flex 4 - creationIndex for containers

    - by sami
    In Flex 3, we can set the following properties in a container object for deferred instantiation: creationPolicy = "queued" creationIndex = "1" (or "2" or "3" etc.) In Flex 4, for I can find the creationPolicy property but there is no creationIndex - trying to set the creationIndex throws a "deprecated" warning but there is no hint on what to use otherwise Any ideas? Thanks - Sami

    Read the article

  • IoC, Containers, and NServiceBus confusion

    - by andy
    Hey guys, here's my setup Castle Windsor is my container NServiceBus is itself using it's own container internally, Spring by default I'm implementing the PubSub config. Ok, if I have my Bus.Publish happening within my IWantToRunAtStartup class, then everything is fine. As a test for example on Run() we can start a timer and it'll go into a Service style loop. However, what if I want to abstract NServiceBus from my app, and have my app go: new CustomPulisherClass().Notify(ISomeMessage msg); In this situation, how do I implement CustomPublisherClass. My confusion is coming from the fact that NServiceBus is already running as a Service, it's already been "Started". How to I get at the correct instance of the Bus object? cheers andy

    Read the article

  • Using collections/containers/catalogs in Domain Models

    - by devoured elysium
    Let's say I want to model a cinema. The cinema will have a couple of rooms(for example, 7), where the movies are being played. I wonder how should I design the domain model for this scenario. Should the Cinema class concept concept have a direct association with the 7 rooms? Should the Cinema class concept have an association with a catalog of the 7 rooms? Why? I am having some trouble understanding why in some places I see the first case and in some others I see something like the second case. If instead of rooms, I wanted to depict the relationship between Cinema and: Tickets to sell (today). Tickets already sold (today) Customers in the Cinema database The set of hours at which there are movies playing in a given room in the cinema. The set of places you can sit at in a room in the cinema. Should I use catalogs, should I connect them directly to the Cinema concept with a multiplicity of * in the target? Thanks

    Read the article

  • Indices instead of pointers in STL containers?

    - by zvrba
    Due to specific requirements [*], I need a singly-linked list implementation that uses integer indices instead of pointers to link nodes. The indices are always interpreted with respect to a vector containing the list nodes. I thought I might achieve this by defining my own allocator, but looking into the gcc's implementation of , they explicitly use pointers for the link fields in the list nodes (i.e., they do not use the pointer type provided by the allocator): struct _List_node_base { _List_node_base* _M_next; ///< Self-explanatory _List_node_base* _M_prev; ///< Self-explanatory ... } (For this purpose, the allocator interface is also deficient in that it does not define a dereference function; "dereferencing" an integer index always needs a pointer to the underlying storage.) Do you know a library of STL-like data structures (i am mostly in need of singly- and doubly-linked list) that use indices (wrt. a base vector) instead of pointers to link nodes? [*] Saving space: the lists will contain many 32-bit integers. With two pointers per node (STL list is doubly-linked), the overhead is 200%, or 400% on 64-bit platform, not counting the overhead of the default allocator.

    Read the article

  • What performance overhead do IoC containers involve?

    - by Sosh
    Hi, Loose coupling is wonderful of course, but I have often wondered what overhead wiring up dynamically using an IoC container (for example Castle Windsor) has over a tightly coupled system? I know that a detailed answer would depend on what the IoC was being used for, but I'm really just trying to get a feel for the magnitude of effort involved in the IoC work. Does anyone have any stats or other resources regarding this? Thanks

    Read the article

  • Using __str__ representation for printing objects in containers in Python

    - by BobDobbs
    I've noticed that when an instance with an overloaded str method is passed to the print() function as an argument, it prints as intended. However, when passing a container that contains one of those instances to print(), it uses the repr method instead. That is to say, print(x) displays the correct string representation of x, and print(x, y) works correctly, but print([x]) or print((x, y)) prints the repr representation instead. First off, why does this happen? Secondly, is there a way to correct that behavior of print() in this circumstance?

    Read the article

  • C++ containers on classes, returning pointers

    - by otneil
    Hello, I'm having some trouble to find the best way to accomplish what I have in mind due to my inexperience. I have a class where I need to a vector of objects. So my first question will be: is there any problem having this: vector< AnyType container* and then on the constructor initialize it with new (and deleting it on the destructor)? Another question is: if this vector is going to store objects, shouldn't it be more like vector< AnyTipe* so they could be dynamically created? In that case how would I return an object from a method and how to avoid memory leaks (trying to use only STL)?

    Read the article

  • Twitter Bootstrap: How to use containers and rows

    - by StackOverflowNewbie
    Assume the following layout: I'm trying to learn how to use Twitter's Bootstrap. What should the general structure of the framework's markup be? Is it this: <div class="container-fluid"> <div class="row-fluid"> <div class="span12"> // Outside link mark up here </div> </div> </div> <div class="container-fluid"> <div class="row-fluid"> <div class="span1"> // Logo mark up here </div> <div class="span4"> // Main nav mark up here </div> <div class="span3 offset4"> // User nav mark up here </div> </div> </div> <div class="container-fluid"> <div class="row-fluid"> <div class="span3"> // Left sidebar mark up here </div> <div class="span6"> <div class="span6"> // Breadcrumb mark up here </div> <div class="span6"> // Main content mark up here </div> </div> <div class="span3"> // Right sidebar mark up here </div> </div> </div> <div class="container-fluid"> <div class="row-fluid"> <div class="span3 offset9"> // Footer link mark up here </div> </div> </div>

    Read the article

  • CSS Containers and Framing

    - by CaffeineAddiction
    I am attempting to code a dynamic object for use in an unordered list. I have a mock up of the HTML here: <ul class='Main'> <li class='Node'> <span class='Node_Light'> </span> <span class='Node_Control'> <span class='Ctrl_Name'> <span class='CtrlN_Text'>Random Name</span> <span class='CtrlN_Edit'>[%]</span> </span><br/> <span class='Ctrl_ID'>ff:ff:ff:ff:ff:ff</span><br/> <span class='Ctrl_Buttons'> <span class='CBttn_On'>[%]</span> <span class='CBttn_Off'>[%]</span> <span class='CBttn_Blink'>[%]</span> <span class='CBttn_Config'>[%]</span> <span class='CBttn_Graph'>[%]</span> </span> </span> <span class='Node_Data'> <span class='ND_Sens0'> <span class='Sens_Lable'>temp:</span> <span class='Sens_Data'>72</span> <span class='Sens_Units'>&#176;F</span> </span><br/> <span class='ND_Sens1'> <span class='Sens_Lable'>Sens1:</span> <span class='Sens_Data'>Off</span> <span class='Sens_Units'></span> </span><br/> <span class='ND_Sens2'> <span class='Sens_Lable'>Sens2:</span> <span class='Sens_Data'>Off</span> <span class='Sens_Units'></span> </span><br/> <span class='ND_Sens3'> <span class='Sens_Lable'>Sens3:</span> <span class='Sens_Data'>Off</span> <span class='Sens_Units'></span> </span><br/> <span class='ND_Sens4'> <span class='Sens_Lable'>Sens4:</span> <span class='Sens_Data'>Off</span> <span class='Sens_Units'></span> </span> </span> </li> </ul> and I am attempting to wrangle this HTML into something like: My first problem was that the 3x Outer elements would stack vertically instead of horizontally ... I solved this with the following CSS, but it doesnt feel like the right solution: ul { list-style-type: none; padding:0; margin:0; } .Node { } .Node_Light { height:6em; width:2em; position:absolute; border-style:solid; border-width:1px; } .Node_Control { height:6em; width:15em; position:absolute; left:2.55em; border-style:solid; border-width:1px; } .Node_Data { height:6em; width:6em; position:absolute; left:17.6em; border-style:solid; border-width:1px; } One thought was to use a table, but I dont think that is the correct solution either. Ideas? I would like to have the content dynamically resize on page resize and am not opposed to doing it all via JavaScript, but I have a feeling it would be more efficient to do it via CSS ... I just dont know where to begin.

    Read the article

  • How to load/save C++ class instance (using STL containers) to disk

    - by supert
    I have a C++ class representing a hierarchically organised data tree which is very large (~Gb, basically as large as I can get away with in memory). It uses an STL list to store information at each node plus iterators to other nodes. Each node has only one parent, but 0-10 children. Abstracted, it looks something like: struct node { public: node_list_iterator parent; // iterator to a single parent node double node_data_array[X]; map<int,node_list_iterator> children; // iterators to child nodes }; class strategy { private: list<node> tree; // hierarchically linked list of nodes struct some_other_data; public: void build(); // build the tree void save(); // save the tree from disk void load(); // load the tree from disk void use(); // use the tree }; I would like to implement the load() and save() to disk, and it should be fairly fast, however the obvious problems are: I don't know the size in advance; The data contains iterators, which are volatile; My ignorance of C++ is prodigious. Could anyone suggest a pure C++ solution please?

    Read the article

  • Can I use MFC objects in STL containers?

    - by Jesse Stimpson
    The following code doesn't compile for me in MSVC2005: std::vector<CMenu> vec(10); CMenu is an MFC menu object (such as a context menu). Through some testing I learned that CMenu does not have a public copy constructor. To do what I wanted to do, I needed to use a dynamic array. CMenu* menus = new CMenu[10]; // ... delete [] menus; Of course, now I've lost all the benefits of using an STL container. Do I have any other options?

    Read the article

  • Adapting non-iterable containers to be iterated via custom templatized iterator

    - by DAldridge
    I have some classes, which for various reasons out of scope of this discussion, I cannot modify (irrelevant implementation details omitted): class Foo { /* ... irrelevant public interface ... */ }; class Bar { public: Foo& get_foo(size_t index) { /* whatever */ } size_t size_foo() { /* whatever */ } }; (There are many similar 'Foo' and 'Bar' classes I'm dealing with, and it's all generated code from elsewhere and stuff I don't want to subclass, etc.) [Edit: clarification - although there are many similar 'Foo' and 'Bar' classes, it is guaranteed that each "outer" class will have the getter and size methods. Only the getter method name and return type will differ for each "outer", based on whatever it's "inner" contained type is. So, if I have Baz which contains Quux instances, there will be Quux& Baz::get_quux(size_t index), and size_t Baz::size_quux().] Given the design of the Bar class, you cannot easily use it in STL algorithms (e.g. for_each, find_if, etc.), and must do imperative loops rather than taking a functional approach (reasons why I prefer the latter is also out of scope for this discussion): Bar b; size_t numFoo = b.size_foo(); for (int fooIdx = 0; fooIdx < numFoo; ++fooIdx) { Foo& f = b.get_foo(fooIdx); /* ... do stuff with 'f' ... */ } So... I've never created a custom iterator, and after reading various questions/answers on S.O. about iterator_traits and the like, I came up with this (currently half-baked) "solution": First, the custom iterator mechanism (NOTE: all uses of 'function' and 'bind' are from std::tr1 in MSVC9): // Iterator mechanism... template <typename TOuter, typename TInner> class ContainerIterator : public std::iterator<std::input_iterator_tag, TInner> { public: typedef function<TInner& (size_t)> func_type; ContainerIterator(const ContainerIterator& other) : mFunc(other.mFunc), mIndex(other.mIndex) {} ContainerIterator& operator++() { ++mIndex; return *this; } bool operator==(const ContainerIterator& other) { return ((mFunc.target<TOuter>() == other.mFunc.target<TOuter>()) && (mIndex == other.mIndex)); } bool operator!=(const ContainerIterator& other) { return !(*this == other); } TInner& operator*() { return mFunc(mIndex); } private: template<typename TOuter, typename TInner> friend class ContainerProxy; ContainerIterator(func_type func, size_t index = 0) : mFunc(func), mIndex(index) {} function<TInner& (size_t)> mFunc; size_t mIndex; }; Next, the mechanism by which I get valid iterators representing begin and end of the inner container: // Proxy(?) to the outer class instance, providing a way to get begin() and end() // iterators to the inner contained instances... template <typename TOuter, typename TInner> class ContainerProxy { public: typedef function<TInner& (size_t)> access_func_type; typedef function<size_t ()> size_func_type; typedef ContainerIterator<TOuter, TInner> iter_type; ContainerProxy(access_func_type accessFunc, size_func_type sizeFunc) : mAccessFunc(accessFunc), mSizeFunc(sizeFunc) {} iter_type begin() const { size_t numItems = mSizeFunc(); if (0 == numItems) return end(); else return ContainerIterator<TOuter, TInner>(mAccessFunc, 0); } iter_type end() const { size_t numItems = mSizeFunc(); return ContainerIterator<TOuter, TInner>(mAccessFunc, numItems); } private: access_func_type mAccessFunc; size_func_type mSizeFunc; }; I can use these classes in the following manner: // Sample function object for taking action on an LMX inner class instance yielded // by iteration... template <typename TInner> class SomeTInnerFunctor { public: void operator()(const TInner& inner) { /* ... whatever ... */ } }; // Example of iterating over an outer class instance's inner container... Bar b; /* assume populated which contained items ... */ ContainerProxy<Bar, Foo> bProxy( bind(&Bar::get_foo, b, _1), bind(&Bar::size_foo, b)); for_each(bProxy.begin(), bProxy.end(), SomeTInnerFunctor<Foo>()); Empirically, this solution functions correctly (minus any copy/paste or typos I may have introduced when editing the above for brevity). So, finally, the actual question: I don't like requiring the use of bind() and _1 placeholders, etcetera by the caller. All they really care about is: outer type, inner type, outer type's method to fetch inner instances, outer type's method to fetch count inner instances. Is there any way to "hide" the bind in the body of the template classes somehow? I've been unable to find a way to separately supply template parameters for the types and inner methods separately... Thanks! David

    Read the article

  • lambda+for_each+delete on STL containers

    - by rubenvb
    I'm trying to get a simple delete every pointer in my vector/list/... function written with an ultra cool lambda function. Mind you, I don't know c**p about those things :) template <typename T> void delete_clear(T const& cont) { for_each(T.begin(), T.end(), [](???){ ???->delete() } ); T.clear(); } I have no clue what to fill in for the ???'s. Any help is greatly appreciated!

    Read the article

  • Toggling between states on 3 containers in jQuery

    - by Saif Bechan
    Hello, i have an php/mysql/ajax auction application application. Now there is a section that can have 3 states. State one, the user can place a bid.(Bid button is shown) State two, the user has to wait before he can place a new bid(number of sec is shown) State three, the user has an auto bidding system enabled.(The price maximum and amount ate shown). Now i get these values trough jquery ajax, and i want to present the user the right section. Now the code i have is as follows: if(data[i].bidwait >= 0 && data[i].amount == ''){ // In this section the user has no autobiddings, and can place a bidding $(productContainer+' .bid-wrapper').removeClass('none'); $(productContainer+' .bidwait-wrapper').addClass('none'); $(productContainer+' .autobid-wrapper').addClass('none'); }else if(data[i].bidwait < 0 && data[i].amount == ''){ // In this section the user has to wait the amount of sec to place a new bid $(productContainer+' .bid-wrapper').addClass('none'); $(productContainer+' .bidwait-wrapper').removeClass('none'); $(productContainer+' .autobid-wrapper').addClass('none'); $(productContainer+' .bidwait-text').text(data[i].bidwait * -1); }else{ // In the last section the user has the auto bidder enabled, so that is shown $(productContainer+' .bid-wrapper').addClass('none'); $(productContainer+' .bidwait-wrapper').addClass('none'); $(productContainer+' .autobid-wrapper').removeClass('none'); $(productContainer+' .amount').html(data[i].amount == 0 ? '&#8734;' : data[i].amount); $(productContainer+' .maxprice').html(data[i].maxprice == 0 ? '&#8734;' : data[i].maxprice); } This looks like an awful lot of code for something so small. I was wondering if there is an easier method to accomplish such a thing. Speed is a huge issue for me because this has to run every second in the users browser. If there is no other option i am just going to remove this option and go with a no ajax approuch. If you have been, thank you for reading!

    Read the article

  • jQuery center multiple dynamic images in different sized containers

    - by JVK Design
    So I've found similar questions but none that answer all the questions I have and I know there must be a simple jQuery answer to this. I've got multiple images that are being dynamically placed in their own containing div that have overflow:hidden, they need to fill their containing divs and be centered(horizontally and vertically) also. The containing divs will be different sizes as well. So in short: multiple different sized images fill and center in containing div. containing divs will be different sizes. will be used multiple times on a page. Hopefully this image helps explain what I'm after. Click here to view the image. HTML I'm using but can be changed <div class="imageHolder"> <div class="first SlideImage"> <img src="..." alt="..."/> </div> <div class="second SlideImage"> <img src="..." alt="..."/> </div> <div class="third SlideImage"> <img src="..." alt="..."/> </div> </div> And the CSS .imageHandler{ float:left; width:764px; height:70px; margin:1px 0px 0px; } .imageHolder .SlideImage{ float:left; position:relative; overflow:hidden; } .imageHolder .SlideImage img{ position:absolute; } .imageHolder .first.SlideImage{ width:381px; height:339px; margin-right:1px; } .imageHolder .second.SlideImage{margin-bottom:1px;} .imageHolder .second.SlideImage, .imageHolder .third.SlideImage { width: 382px; height: 169px; } Ask me anything if this doesn't make sense, thanks in advance

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >