Changeset 187

Show
Ignore:
Timestamp:
03/23/09 10:51:57 (15 years ago)
Author:
bhilburn
Message:

Abandoning the RemoteComponent? struct; migrating to a simple socketFD
and boolean field.

Location:
vtcross/trunk/src
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • vtcross/trunk/src/include/vtcross/components.h

    r186 r187  
    7878        virtual void RegisterServices(int32_t socketFD) = 0; 
    7979        virtual void DeregisterServices(int32_t socketFD) = 0; 
    80  
    81  
    82         /* The RemoteComponent struct represents either the VTCROSS shell or the 
    83          * VTCROSS SML.  If 'SML_present' is false, it is the former. Otherwise, 
    84          * it is the latter. 
    85          */ 
    86         bool SML_present; 
    87         struct RemoteComponent *control; 
    8880}; 
    8981 
     
    186178        void ValidateParameters(struct Parameter pList[], \ 
    187179                struct CE_Info *ce_info, int decision_array[]); 
     180 
     181 
     182        /* The SML_present bool reflects whether or not the remote component 
     183         * this object is connected to is an SML.  If it isn't, then it must be 
     184         * a shell.  The socketFD stores the socket file descriptor for this 
     185         * connection. 
     186         */ 
     187        bool SML_present; 
     188        int32_t socketFD; 
    188189}; 
    189190 
     
    239240                Parameter *parameters, std::string service); 
    240241 
    241  
    242         /* Contains information regarding the presence of a service management 
    243          * layer.  If this pointer is NULL, then there is no SML present in the 
    244          * radio system. 
    245          */ 
    246         struct SML_Info *SML; 
     242        /* The SML_present bool reflects whether or not the remote component 
     243         * this object is connected to is an SML.  If it isn't, then it must be 
     244         * a shell.  The socketFD stores the socket file descriptor for this 
     245         * connection. 
     246         */ 
     247        bool SML_present; 
     248        int32_t socketFD; 
    247249}; 
    248250 
  • vtcross/trunk/src/include/vtcross/containers.h

    r186 r187  
    7777}; 
    7878 
    79  
    80 /* Contains information regarding a remote component in a VTCROSS system.  Note 
    81  * that this information is independent of component type, but technically will 
    82  * only ever be the SML or shell. 
    83  * 
    84  * TODO I'm not 100% certain I'm doing this in the most efficient way.  Need 
    85  * someone to look it over. 
    86  */ 
    87 struct RemoteComponent { 
    88     std::string serverName; 
    89     int32_t serverPort; 
    90     int32_t socketFD; 
    91 }; 
    92  
    9379#endif 
  • vtcross/trunk/src/include/vtcross/socketcomm.h

    r184 r187  
    3939 
    4040 
    41 /* TODO 
    42  * This is meant as the future replacement for the function below it.  It is 
    43  * still a work in progress, and needs a code-review before we move to it 
    44  * entirely. 
    45  */ 
    46 void CreateClientSocket(struct RemoteComponent* serverInfo); 
    47  
    48  
    4941/* This is the original function that does what the above function is supposed 
    5042 * to do. 
  • vtcross/trunk/src/lib/socketcomm/socketcomm.cpp

    r186 r187  
    7676} 
    7777 
    78  
    79 /* TODO see notes in socketcomm.h. This function, and the RemoteComponent 
    80  * struct, need a code review to make sure it is ready to be used rather 
    81  * than ClientSocket() 
    82  */ 
    83 void 
    84 CreateClientSocket(struct RemoteComponent* serverInfo) 
    85 { 
    86     if(serverInfo == NULL) 
    87         ERROR(1, "CreateClientSocket received null struct pointer.\n"); 
    88  
    89     struct hostent *server = gethostbyname(serverInfo->serverName.c_str()); 
    90     if(server == NULL) 
    91         ERROR(1, "No server found by that hostname."); 
    92          
    93     serverInfo->socketFD = socket(AF_INET, SOCK_STREAM, 0); 
    94     if(serverInfo->socketFD < 0)  
    95         ERROR(1, "Error opening socket"); 
    96  
    97     struct sockaddr_in serv_addr; 
    98     memset((void *) &serv_addr, 0, sizeof(serv_addr)); 
    99     serv_addr.sin_family = AF_INET; 
    100     serv_addr.sin_port = htons(serverInfo->serverPort); 
    101     memcpy((char *) &serv_addr.sin_addr.s_addr, (char *) server->h_addr, \ 
    102             server->h_length); 
    103  
    104     if(connect(serverInfo->socketFD, (struct sockaddr *) &serv_addr, \ 
    105             sizeof(serv_addr)) < 0)  
    106         ERROR(1, "Error connecting to remote socket."); 
    107 } 
    108  
    10978     
    11079/* TODO I'm fairly certain this function is unnecessary, see function below for more details... 
  • vtcross/trunk/src/policy_engines/PolicyEngine.cpp

    r186 r187  
    2525    LOG("Creating Policy Engine.\n"); 
    2626    SML_present = false; 
    27     control = new RemoteComponent; 
    2827    LoadPolicies(); 
    2928} 
     
    3231PolicyEngine::~PolicyEngine() 
    3332{ 
    34     delete control; 
    3533} 
    3634 
     
    4240 
    4341    SML_present = SML; 
    44     control = new RemoteComponent; 
    45     control->serverName = std::string(serverName); 
    46     control->serverPort = atoi(portNumber); 
    4742 
    48     control->socketFD = ClientSocket(serverName, portNumber); 
     43    socketFD = ClientSocket(serverName, portNumber); 
    4944 
    5045    if(SML_present) { 
    51         RegisterServices(control->socketFD); 
     46        RegisterServices(socketFD); 
    5247        LOG("Policy Engine connected to SML at %s.\n", serverName); 
    5348    } 
    5449    else { 
    55         RegisterComponent(control->socketFD); 
     50        RegisterComponent(socketFD); 
    5651        LOG("Policy Engine connected to shell at %s.\n", serverName); 
    5752    } 
     
    9186{ 
    9287    if(SML_present) 
    93         DeregisterServices(control->socketFD); 
     88        DeregisterServices(socketFD); 
    9489    else 
    95         DeregisterComponent(control->socketFD); 
     90        DeregisterComponent(socketFD); 
    9691} 
    9792 
     
    10297    LOG("Resetting Policy Engine.\n"); 
    10398    SML_present = false; 
    104     control = new RemoteComponent; 
     99    socketFD = -1; 
    105100    LoadPolicies(); 
    106101} 
  • vtcross/trunk/src/policy_engines/policy_demo.cpp

    r186 r187  
    3535    LOG("Waiting for signal...\n"); 
    3636    while(1) { 
    37         policyEngine.WaitForSignal(policyEngine.control->socketFD); 
     37//        policyEngine.WaitForSignal(); 
    3838    } 
    3939