Search Results

Search found 3437 results on 138 pages for 'circular dependency'.

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

  • C - circular character buffer w/ pthreads

    - by Matt
    I have a homework assignment where I have to implement a circular buffer and add and remove chars with separate threads: #include <pthread.h> #include <stdio.h> #define QSIZE 10 pthread_cond_t full,/* count == QSIZE */ empty,/* count == 0 */ ready; pthread_mutex_t m, n; /* implements critical section */ unsigned int iBuf, /* tail of circular queue */ oBuf; /* head of circular queue */ int count; /* count characters */ char buf [QSIZE]; /* the circular queue */ void Put(char s[]) {/* add "ch"; wait if full */ pthread_mutex_lock(&m); int size = sizeof(s)/sizeof(char); printf("size: %d", size); int i; for(i = 0; i < size; i++) { while (count >= QSIZE) pthread_cond_wait(&full, &m);/* is there empty slot? */ buf[iBuf] = s[i]; /* store the character */ iBuf = (iBuf+1) % QSIZE; /* increment mod QSIZE */ count++; if (count == 1) pthread_cond_signal(&empty);/* new character available */ } pthread_mutex_unlock(&m); } char Get() {/* remove "ch" from queue; wait if empty */ char ch; pthread_mutex_lock(&m); while (count <= 0) pthread_cond_wait(&empty, &m);/* is a character present? */ ch = buf[oBuf]; /* retrieve from the head of the queue */ oBuf = (oBuf+1) % QSIZE; count--; if (count == QSIZE-1) pthread_cond_signal(&full);/* signal existence of a slot */ pthread_mutex_unlock(&m); return ch; } void * p1(void *arg) { int i; for (i = 0; i < 5; i++) { Put("hella"); } } void * p2(void *arg) { int i; for (i = 0; i < 5; i++) { Put("goodby"); } } int main() { pthread_t t1, t2; void *r1, *r2; oBuf = 0; iBuf = 0; count=0; /* all slots are empty */ pthread_cond_init(&full, NULL); pthread_cond_init(&empty, NULL); pthread_mutex_init(&m, NULL); pthread_create(&t1, NULL, p1, &r1); pthread_create(&t2, NULL, p2, &r2); printf("Main"); char c; int i = 0; while (i < 55) { c = Get(); printf("%c",c); i++; } pthread_join(t1, &r1); pthread_join(t2, &r2); return 0; } I shouldn't have to change the logic much at all, the requirements are pretty specific. I think my problem lies in the Put() method. I think the first thread is going in and blocking the critical section and causing a deadlock. I was thinking I should make a scheduling attribute? Of course I could be wrong. I am pretty new to pthreads and concurrent programming, so I could really use some help spotting my error.

    Read the article

  • apt-get install fails due to dependency issues but apt-get -f install won't fix it

    - by user71941
    I've just installed Ubuntu 12.04 and was about to manually install Rawstudio with the packages from SourceForge repo, but I've been stuck with dependency issues and I am short on apt command lines to sort this out. Here's the report I'v got : installArchives() failed: dpkg: dependency problems prevent configuration of libgphoto2-2: libgphoto2-2 depends on libjpeg62; however: Package libjpeg62 is not installed. libgphoto2-l10n (2.4.13-1ubuntu1) breaks libgphoto2-2 (<= 2.4.10.1-4) and is installed. Version of libgphoto2-2 to be configured is 2.4.10.1-0ubuntu3~maverick. dpkg: error processing libgphoto2-2 (--configure): dependency problems - leaving unconfigured No apport report written because MaxReports is reached already dpkg: dependency problems prevent configuration of libgphoto2-2-dev: libgphoto2-2-dev depends on libgphoto2-2 (= 2.4.10.1-0ubuntu3~maverick); however: Package libgphoto2-2 is not configured yet. dpkg: error processing libgphoto2-2-dev (--configure): dependency problems - leaving unconfigured No apport report written because MaxReports is reached already Errors were encountered while processing: libgphoto2-2 libgphoto2-2-dev Error in function: SystemError: E:Sub-process /usr/bin/dpkg returned an error code (1) dpkg: dependency problems prevent configuration of libgphoto2-2: libgphoto2-2 depends on libjpeg62; however: Package libjpeg62 is not installed. libgphoto2-l10n (2.4.13-1ubuntu1) breaks libgphoto2-2 (<= 2.4.10.1-4) and is installed. Version of libgphoto2-2 to be configured is 2.4.10.1-0ubuntu3~maverick. dpkg: error processing libgphoto2-2 (--configure): dependency problems - leaving unconfigured dpkg: dependency problems prevent configuration of libgphoto2-2-dev: libgphoto2-2-dev depends on libgphoto2-2 (= 2.4.10.1-0ubuntu3~maverick); however: Package libgphoto2-2 is not configured yet. dpkg: error processing libgphoto2-2-dev (--configure): dependency problems - leaving unconfigured I've tried "apt-get -f install" but without success. What is the mahick command line that will unblock the situation ? Thanks Seb

    Read the article

  • Questioning the motivation for dependency injection: Why is creating an object graph hard?

    - by oberlies
    Dependency injection frameworks like Google Guice give the following motivation for their usage (source): To construct an object, you first build its dependencies. But to build each dependency, you need its dependencies, and so on. So when you build an object, you really need to build an object graph. Building object graphs by hand is labour intensive (...) and makes testing difficult. But I don't buy this argument: Even without dependency injection, I can write classes which are both easy to instantiate and convenient to test. E.g. the example from the Guice motivation page could be rewritten in the following way: class BillingService { private final CreditCardProcessor processor; private final TransactionLog transactionLog; // constructor for tests, taking all collaborators as parameters BillingService(CreditCardProcessor processor, TransactionLog transactionLog) { this.processor = processor; this.transactionLog = transactionLog; } // constructor for production, calling the (productive) constructors of the collaborators public BillingService() { this(new PaypalCreditCardProcessor(), new DatabaseTransactionLog()); } public Receipt chargeOrder(PizzaOrder order, CreditCard creditCard) { ... } } So dependency injection may really be an advantage in advanced use cases, but I don't need it for easy construction and testability, do I?

    Read the article

  • Can higher-order functions in FP be interpreted as some kind of dependency injection?

    - by Giorgio
    According to this article, in object-oriented programming / design dependency injection involves a dependent consumer, a declaration of a component's dependencies, defined as interface contracts, an injector that creates instances of classes that implement a given dependency interface on request. Let us now consider a higher-order function in a functional programming language, e.g. the Haskell function filter :: (a -> Bool) -> [a] -> [a] from Data.List. This function transforms a list into another list and, in order to perform its job, it uses (consumes) an external predicate function that must be provided by its caller, e.g. the expression filter (\x -> (mod x 2) == 0) [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] selects all even numbers from the input list. But isn't this construction very similar to the pattern illustrated above, where the filter function is the dependent consumer, the signature (a -> Bool) of the function argument is the interface contract, the expression that uses the higher-order is the injector that, in this particular case, injects the implementation (\x -> (mod x 2) == 0) of the contract. More in general, can one relate higher-order functions and their usage pattern in functional programming to the dependency injection pattern in object-oriented languages? Or in the inverse direction, can dependency injection be compared to using some kind of higher-order function?

    Read the article

  • Questioning one of the arguments for dependency injection: Why is creating an object graph hard?

    - by oberlies
    Dependency injection frameworks like Google Guice give the following motivation for their usage (source): To construct an object, you first build its dependencies. But to build each dependency, you need its dependencies, and so on. So when you build an object, you really need to build an object graph. Building object graphs by hand is labour intensive (...) and makes testing difficult. But I don't buy this argument: Even without dependency injection, I can write classes which are both easy to instantiate and convenient to test. E.g. the example from the Guice motivation page could be rewritten in the following way: class BillingService { private final CreditCardProcessor processor; private final TransactionLog transactionLog; // constructor for tests, taking all collaborators as parameters BillingService(CreditCardProcessor processor, TransactionLog transactionLog) { this.processor = processor; this.transactionLog = transactionLog; } // constructor for production, calling the (productive) constructors of the collaborators public BillingService() { this(new PaypalCreditCardProcessor(), new DatabaseTransactionLog()); } public Receipt chargeOrder(PizzaOrder order, CreditCard creditCard) { ... } } So there may be other arguments for dependency injection (which are out of scope for this question!), but easy creation of testable object graphs is not one of them, is it?

    Read the article

  • Dependency Injection in ASP.NET MVC NerdDinner App using Ninject

    - by shiju
    In this post, I am applying Dependency Injection to the NerdDinner application using Ninject. The controllers of NerdDinner application have Dependency Injection enabled constructors. So we can apply Dependency Injection through constructor without change any existing code. A Dependency Injection framework injects the dependencies into a class when the dependencies are needed. Dependency Injection enables looser coupling between classes and their dependencies and provides better testability of an application and it removes the need for clients to know about their dependencies and how to create them. If you are not familiar with Dependency Injection and Inversion of Control (IoC), read Martin Fowler’s article Inversion of Control Containers and the Dependency Injection pattern. The Open Source Project NerDinner is a great resource for learning ASP.NET MVC.  A free eBook provides an end-to-end walkthrough of building NerdDinner.com application. The free eBook and the Open Source Nerddinner application are extremely useful if anyone is trying to lean ASP.NET MVC. The first release of  Nerddinner was as a sample for the first chapter of Professional ASP.NET MVC 1.0. Currently the application is updating to ASP.NET MVC 2 and you can get the latest source from the source code tab of Nerddinner at http://nerddinner.codeplex.com/SourceControl/list/changesets. I have taken the latest ASP.NET MVC 2 source code of the application and applied  Dependency Injection using Ninject and Ninject extension Ninject.Web.Mvc.Ninject &  Ninject.Web.MvcNinject is available at http://github.com/enkari/ninject and Ninject.Web.Mvc is available at http://github.com/enkari/ninject.web.mvcNinject is a lightweight and a great dependency injection framework for .NET.  Ninject is a great choice of dependency injection framework when building ASP.NET MVC applications. Ninject.Web.Mvc is an extension for ninject which providing integration with ASP.NET MVC.Controller constructors and dependencies of NerdDinner application Listing 1 – Constructor of DinnersController  public DinnersController(IDinnerRepository repository) {     dinnerRepository = repository; }  Listing 2 – Constrcutor of AccountControllerpublic AccountController(IFormsAuthentication formsAuth, IMembershipService service) {     FormsAuth = formsAuth ?? new FormsAuthenticationService();     MembershipService = service ?? new AccountMembershipService(); }  Listing 3 – Constructor of AccountMembership – Concrete class of IMembershipService public AccountMembershipService(MembershipProvider provider) {     _provider = provider ?? Membership.Provider; }    Dependencies of NerdDinnerDinnersController, RSVPController SearchController and ServicesController have a dependency with IDinnerRepositiry. The concrete implementation of IDinnerRepositiry is DinnerRepositiry. AccountController has dependencies with IFormsAuthentication and IMembershipService. The concrete implementation of IFormsAuthentication is FormsAuthenticationService and the concrete implementation of IMembershipService is AccountMembershipService. The AccountMembershipService has a dependency with ASP.NET Membership Provider. Dependency Injection in NerdDinner using NinjectThe below steps will configure Ninject to apply controller injection in NerdDinner application.Step 1 – Add reference for NinjectOpen the  NerdDinner application and add  reference to Ninject.dll and Ninject.Web.Mvc.dll. Both are available from http://github.com/enkari/ninject and http://github.com/enkari/ninject.web.mvcStep 2 – Extend HttpApplication with NinjectHttpApplication Ninject.Web.Mvc extension allows integration between the Ninject and ASP.NET MVC. For this, you have to extend your HttpApplication with NinjectHttpApplication. Open the Global.asax.cs and inherit your MVC application from  NinjectHttpApplication instead of HttpApplication.   public class MvcApplication : NinjectHttpApplication Then the Application_Start method should be replace with OnApplicationStarted method. Inside the OnApplicationStarted method, call the RegisterAllControllersIn() method.   protected override void OnApplicationStarted() {     AreaRegistration.RegisterAllAreas();     RegisterRoutes(RouteTable.Routes);     ViewEngines.Engines.Clear();     ViewEngines.Engines.Add(new MobileCapableWebFormViewEngine());     RegisterAllControllersIn(Assembly.GetExecutingAssembly()); }  The RegisterAllControllersIn method will enables to activating all controllers through Ninject in the assembly you have supplied .We are passing the current assembly as parameter for RegisterAllControllersIn() method. Now we can expose dependencies of controller constructors and properties to request injectionsStep 3 – Create Ninject ModulesWe can configure your dependency injection mapping information using Ninject Modules.Modules just need to implement the INinjectModule interface, but most should extend the NinjectModule class for simplicity. internal class ServiceModule : NinjectModule {     public override void Load()     {                    Bind<IFormsAuthentication>().To<FormsAuthenticationService>();         Bind<IMembershipService>().To<AccountMembershipService>();                  Bind<MembershipProvider>().ToConstant(Membership.Provider);         Bind<IDinnerRepository>().To<DinnerRepository>();     } } The above Binding inforamtion specified in the Load method tells the Ninject container that, to inject instance of DinnerRepositiry when there is a request for IDinnerRepositiry and  inject instance of FormsAuthenticationService when there is a request for IFormsAuthentication and inject instance of AccountMembershipService when there is a request for IMembershipService. The AccountMembershipService class has a dependency with ASP.NET Membership provider. So we configure that inject the instance of Membership Provider. When configuring the binding information, you can specify the object scope in you application.There are four built-in scopes available in Ninject:Transient  -  A new instance of the type will be created each time one is requested. (This is the default scope). Binding method is .InTransientScope()   Singleton - Only a single instance of the type will be created, and the same instance will be returned for each subsequent request. Binding method is .InSingletonScope()Thread -  One instance of the type will be created per thread. Binding method is .InThreadScope() Request -  One instance of the type will be created per web request, and will be destroyed when the request ends. Binding method is .InRequestScope() Step 4 – Configure the Ninject KernelOnce you create NinjectModule, you load them into a container called the kernel. To request an instance of a type from Ninject, you call the Get() extension method. We can configure the kernel, through the CreateKernel method in the Global.asax.cs. protected override IKernel CreateKernel() {     var modules = new INinjectModule[]     {         new ServiceModule()     };       return new StandardKernel(modules); } Here we are loading the Ninject Module (ServiceModule class created in the step 3)  onto the container called the kernel for performing dependency injection.Source CodeYou can download the source code from http://nerddinneraddons.codeplex.com. I just put the modified source code onto CodePlex repository. The repository will update with more add-ons for the NerdDinner application.

    Read the article

  • typedef struct, circular dependency, forward definitions

    - by BlueChip
    The problem I have is a circular dependency issue in C header files ...Having looked around I suspect the solution will have something to do with Forward Definitions, but although there are many similar problems listed, none seem to offer the information I require to resolve this one... I have the following 5 source files: // fwd1.h #ifndef __FWD1_H #define __FWD1_H #include "fwd2.h" typedef struct Fwd1 { Fwd2 *f; } Fwd1; void fwd1 (Fwd1 *f1, Fwd2 *f2) ; #endif // __FWD1_H . // fwd1.c #include "fwd1.h" #include "fwd2.h" void fwd1 (Fwd1 *f1, Fwd2 *f2) { return; } . // fwd2.h #ifndef __FWD2_H #define __FWD2_H #include "fwd1.h" typedef struct Fwd2 { Fwd1 *f; } Fwd2; void fwd2 (Fwd1 *f1, Fwd2 *f2) ; #endif // __FWD2_H . // fwd2.c #include "fwd1.h" #include "fwd2.h" void fwd2 (Fwd1 *f1, Fwd2 *f2) { return; } . // fwdMain.c #include "fwd1.h" #include "fwd2.h" int main (int argc, char** argv, char** env) { Fwd1 *f1 = (Fwd1*)0; Fwd2 *f2 = (Fwd2*)0; fwd1(f1, f2); fwd2(f1, f2); return 0; } Which I am compiling with the command: gcc fwdMain.c fwd1.c fwd2.c -o fwd -Wall I have tried several ideas to resolve the compile errors, but have only managed to replace the errors with other errors ...How do I resolve the circular dependency issue with the least changes to my code? ...Ideally, as a matter of coding style, I would like to avoid putting the word "struct" all over my code.

    Read the article

  • Dependency isn't included in my assembly, although scope is "compile"

    - by Bernhard V
    Hi! I have the following dependency specified in my project's pom: <dependency> <groupId>org.jboss.client</groupId> <artifactId>jbossall-client</artifactId> <scope>compile</scope> </dependency> My project itself has to be the child of another pom. And in that one, the following is defined: <dependency> <groupId>jboss</groupId> <artifactId>jbossall-client</artifactId> <version>4.2.2</version> <scope>provided</scope> <type>jar</type> </dependency> When I now assembly my program, it seems that the "provided" scope of the parent pom overrides the scope of my project, since the jbossall-client-jar is not included in my assembly. Although it seems illogical to me, maybe it's this feature taking effect here. Do you know a way to include the dependency in my assembly without touching the parent pom?

    Read the article

  • Missing Dependency Errors when Installing OpenVas Server

    - by David
    I'm trying to install OpenVAS on Red Hat Enterprise Linux 5.5. I've successfully run yum install openvas-client, but yum install openvas-server prints the following errors: --> Finished Dependency Resolution openvas-client-3.0.1-1.el5.art.i386 from installed has depsolving problems --> Missing Dependency: libopenvas_hg.so.3 is needed by package openvas-client-3.0.1-1.el5.art.i386 (installed) openvas-client-3.0.1-1.el5.art.i386 from installed has depsolving problems --> Missing Dependency: libopenvas_nasl.so.3 is needed by package openvas-client-3.0.1-1.el5.art.i386 (installed) openvas-client-3.0.1-1.el5.art.i386 from installed has depsolving problems --> Missing Dependency: libopenvas_omp.so.3 is needed by package openvas-client-3.0.1-1.el5.art.i386 (installed) openvas-scanner-3.2-0.2.el5.art.i386 from atomic has depsolving problems --> Missing Dependency: net-snmp-utils is needed by package openvas-scanner-3.2-0.2.el5.art.i386 (atomic) openvas-client-3.0.1-1.el5.art.i386 from installed has depsolving problems --> Missing Dependency: libopenvas_misc.so.3 is needed by package openvas-client-3.0.1-1.el5.art.i386 (installed) openvas-scanner-3.2-0.2.el5.art.i386 from atomic has depsolving problems --> Missing Dependency: openldap-clients is needed by package openvas-scanner-3.2-0.2.el5.art.i386 (atomic) openvas-client-3.0.1-1.el5.art.i386 from installed has depsolving problems --> Missing Dependency: libopenvas_base.so.3 is needed by package openvas-client-3.0.1-1.el5.art.i386 (installed) Error: Missing Dependency: net-snmp-utils is needed by package openvas-scanner-3.2-0.2.el5.art.i386 (atomic) Error: Missing Dependency: libopenvas_base.so.3 is needed by package openvas-client-3.0.1-1.el5.art.i386 (installed) Error: Missing Dependency: libopenvas_hg.so.3 is needed by package openvas-client-3.0.1-1.el5.art.i386 (installed) Error: Missing Dependency: libopenvas_nasl.so.3 is needed by package openvas-client-3.0.1-1.el5.art.i386 (installed) Error: Missing Dependency: openldap-clients is needed by package openvas-scanner-3.2-0.2.el5.art.i386 (atomic) Error: Missing Dependency: libopenvas_omp.so.3 is needed by package openvas-client-3.0.1-1.el5.art.i386 (installed) Error: Missing Dependency: libopenvas_misc.so.3 is needed by package openvas-client-3.0.1-1.el5.art.i386 (installed) You could try using --skip-broken to work around the problem You could try running: package-cleanup --problems package-cleanup --dupes rpm -Va --nofiles --nodigest The program package-cleanup is found in the yum-utils package. Notice that each of the missing dependencies is followed by the words (installed) or the words (atomic) - for the name of the repository. When I try to install any of these sub-dependencies, the installation fails (either due to missing dependencies or since the rpm is already installed). For example, if I try to install a rpm for "libopenvas_hg.so.3", I get an error message indicating that it is already installed. Yet "libopenvas_hg.so.3" is listed as a missing dependency. Why? Do I need to uninstall all of the "missing" dependences first?

    Read the article

  • Make circular joystick

    - by Jaba
    How do I make a joystick like the one in i dig it, using UIImageView's that the smaller one can be used to move around, I just really would like to know how I would get the smaller UIImageView to stay inside the larger one, I just don't know how I would do this because they are both circular. I have an Image below:

    Read the article

  • iPhone Circular Progress Indicator

    - by Ward
    I'm trying to create a circular progress indicator like Shazam. It will represent progress during recording. There will be a finite amount of time and I want it to react to the sound level like Shazam's does. Any clues where to begin? Thanks

    Read the article

  • a design to avoid circular reference in this scenario

    - by BDotA
    Here is our dependency tree: BigApp - Child Apps - Libraries ALL of our components are HEAVILY using one of the Libraries as above ( LibA). But it has a ‘few’ public methods that require classes from ‘higher-level’ assemblies and we want to avoid CIRCULAR references. What do you propose as a good design for this?

    Read the article

  • Database design: circular references

    - by SlappyTheFish
    I have three database tables: users emails invitations Emails are linked to users by a user_id field. Invitations are also linked to users by a user_id field Emails can be created without an invitation, but every invitation must have an email. I would like to link the emails and invitations tables so it is possible to find the email for a particular invitation. However this creates a circular reference, both an invitation and an email record hold the id for the same user. Is this bad design and if so, how could I improve it? My feeling is that with use of foreign keys and good business logic, it is fine.

    Read the article

  • Circular Dependency Solution

    - by gfoley
    Our current project has ran into a circular dependency issue. Our business logic assembly is using classes and static methods from our SharedLibrary assembly. The SharedLibrary contains a whole bunch of helper functions, such as a SQL Reader class, Enumerators, Global Variables, Error Handling, Logging and Validation. The SharedLibrary needs access to the Business objects, but the Business objects need access to SharedLibrary. The old developers solved this obvious code smell by replicating the functionality of the business objects in the shared library (very anti-DRY). I've spent a day now trying to read about my options to solve this but i'm hitting a dead end. I'm open to the idea of architecture redesign, but only as a last resort. So how can i have a Shared Helper Library which can access the business objects, with the business objects still accessing the Shared Helper Library?

    Read the article

  • Test if single linked list is circular by traversing it only once

    - by user1589754
    I am a fresher and I was asked this question in a recent interview I gave. The question was --- By traversing each element of linked list just once find if the single linked list is circular at any point. To this I answered that we will store reference of each node while traversing the list in another linked list and for every node in the list being tested we will find if the reference exists in the list I am storing the references. The interviewer said that he needs a more optimized way to solve this problem. Can anyone please tell me what would be a more optimized method to solve this problem.

    Read the article

  • Circular reference problem Singleton

    - by Ismail
    I'm trying to creating a Singleton class like below where MyRepository lies in separate DAL project. It's causing me a circular reference problem because GetMySingleTon() method returns MySingleTon class and needs its access. Same way I need MyRepository access in constructor of MySingleTon class. public class MySingleTon { static MySingleTon() { if (Instance == null) { MyRepository rep = new MyRepository(); Instance = rep.GetMySingleTon(); } } public static MySingleTon Instance { get; private set; } public string prop1 { get; set; } public string prop2 { get; set; } }

    Read the article

  • DB Design - Linking to a parent without circular reference issues

    - by zSysop
    Hi all, I'm having trouble coming up with a solution for the following issue. Lets say i have a db that looks something like the following: Issue Table Id | Details | CreateDate | ClosedDate Issue Notes Table Id | ObjectId | Notes | NoteDate Issue Assignment Table Id | ObjectId | AssignedToId| AssignedDate I'd like allow the linking of an issue to another issue. I thought about adding a column to the Issue table called ParentIssueId and that would allow me the ability to link issues, but i foresee circular references occurring within the issue table if i go through with this implementation. Is there a better way to go about doing this, and if so, how? Thanks

    Read the article

  • FRIEND_TEST in Google Test - possible circular dependency?

    - by Mihaela
    I am trying to figure out how FRIEND_TEST works in Google Tests. http://code.google.com/p/googletest/wiki/AdvancedGuide#Private_Class_Members I am looking at the following item, trying to implement it in my code: // foo.h #include "gtest/gtest_prod.h" // Defines FRIEND_TEST. class Foo { ... private: FRIEND_TEST(FooTest, BarReturnsZeroOnNull); int Bar(void* x); }; // foo_test.cc ... TEST(FooTest, BarReturnsZeroOnNull) { Foo foo; EXPECT_EQ(0, foo.Bar(NULL)); // Uses Foo's private member Bar(). } In the code above, the piece that I can't see, is that foo_test.cc must include foo.h, in order to have access to Foo and Bar(). [Perhaps it works differently for Google ? in my code, I must include it] That will result in circular dependency... Am I missing something ?

    Read the article

  • How to hash and check for equality of objects with circular references

    - by mfya
    I have a cyclic graph-like structure that is represented by Node objects. A Node is either a scalar value (leaf) or a list of n=1 Nodes (inner node). Because of the possible circular references, I cannot simply use a recursive HashCode() function, that combines the HashCode() of all child nodes: It would end up in an infinite recursion. While the HashCode() part seems at least to be doable by flagging and ignoring already visited nodes, I'm having some troubles to think of a working and efficient algorithm for Equals(). To my surprise I did not find any useful information about this, but I'm sure many smart people have thought about good ways to solve these problems...right? Example (python): A = [ 1, 2, None ]; A[2] = A B = [ 1, 2, None ]; B[2] = B A is equal to B, because it represents exactly the same graph. BTW. This question is not targeted to any specific language, but implementing hashCode() and equals() for the described Node object in Java would be a good practical example.

    Read the article

  • Circular reference while setting up bidirectional communication line between two remote objects

    - by mphair
    I'm using .Net remoting to set up a bidirectional communication line between two objects. The basic structure is as follows: Instances of RemoteObjectA call methods on StaticObjectA. Instances of RemoteObjectB call methods on StaticObjectB. StaticObjectA needs to be able to call methods provided by RemoteObjectB. StaticObjectB needs to be able to call methods provided by RemoteObjectA. The problem with this setup is the circular reference in RemoteObjectA gets StaticObjectA gets RemoteObjectB gets StaticObjectB gets RemoteObjectA... I implemented an interface IRemoteObjectA and IRemoteObjectB and had the remote objects inheret from their respective interfaces, but then setting up the remoting fails. If the solution to this problem is: "don't use remoting", I can deal with that. Just wanted to make sure I wasn't missing a simple solution.

    Read the article

  • Resolve circular typedef dependency?

    - by Nick
    What is the best way to resolve the following circular dependency in typedef-ing these structs? Note the C language tag - I'm looking for a solution in standard gcc C. typedef struct { char* name; int age; int lefthanded; People* friends; } Person; typedef struct { int count; int max; Person* data; } People;

    Read the article

  • Dependency Walker Not Showing All the Depended Dll

    - by Ngu Soon Hui
    I have a fortran dll, and I want to know the assemblies that it depends on for redistribution purpose. One thing I found out is that the dependency walker doesn't show all of the dependencies, i.e, there are some dlls that my assembly is dependent on, but dependency walker doesn't show it out. An example would be a dll that makes use of intel mkl LAPACK dlls, but the dependency walker doesn't show that dependency. Why this is so? And any idea how to fix this problem, or is there other more reliable tool that I can use?

    Read the article

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