Update of /cvsroot/playerstage/code/player/libplayercore
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28405/libplayercore
Modified Files:
configfile.cc configfile.h devicetable.cc devicetable.h
Log Message:
added some hooks to playercore for non-XDR/TCP use
Index: devicetable.cc
===================================================================
RCS file: /cvsroot/playerstage/code/player/libplayercore/devicetable.cc,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** devicetable.cc 23 Aug 2007 19:58:42 -0000 1.20
--- devicetable.cc 7 Mar 2008 02:34:55 -0000 1.21
***************
*** 48,51 ****
--- 48,52 ----
#include <libplayercore/devicetable.h>
#include <libplayercore/interface_util.h>
+ #include <libplayercore/addr_util.h>
// initialize the table
***************
*** 178,181 ****
--- 179,240 ----
}
+ // find a device, based on id, and return the pointer (or NULL on
+ // failure)
+ Device*
+ DeviceTable::GetDevice(const char* str_addr,
+ bool lookup_remote)
+ {
+ player_devaddr_t addr;
+ memset(&addr,0,sizeof(player_devaddr_t));
+
+ char* str_addr_copy = strdup(str_addr);
+ char* colon;
+
+ // Must have an index
+ if(!((colon = strrchr(str_addr_copy,':'))))
+ return(NULL);
+ addr.index = atoi(colon+1);
+ *colon = '\0';
+
+ // Must have an interface (but it might not have a preceding colon)
+ if(!((colon = strrchr(str_addr_copy,':'))))
+ {
+ if(!strlen(str_addr_copy))
+ return(NULL);
+ addr.interf = str_to_interf(str_addr_copy);
+ colon = str_addr_copy;
+ }
+ else
+ {
+ addr.interf = str_to_interf(colon+1);
+ }
+ *colon = '\0';
+
+ // Might have a robot
+ if(!((colon = strrchr(str_addr_copy,':'))))
+ {
+ colon = str_addr_copy;
+ if(strlen(str_addr_copy))
+ addr.robot = atoi(str_addr_copy);
+ }
+ else
+ {
+ addr.robot = atoi(colon+1);
+ }
+ *colon = '\0';
+
+ // Might have a host
+ if(!((colon = strrchr(str_addr_copy,':'))))
+ {
+ if(strlen(str_addr_copy))
+ hostname_to_packedaddr(&addr.host,str_addr_copy);
+ }
+ else
+ hostname_to_packedaddr(&addr.host,colon+1);
+
+
+ return(this->GetDevice(addr,lookup_remote));
+ }
+
// Call Update() on each driver with non-zero subscriptions
//
Index: devicetable.h
===================================================================
RCS file: /cvsroot/playerstage/code/player/libplayercore/devicetable.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** devicetable.h 10 Jul 2007 09:01:51 -0000 1.9
--- devicetable.h 7 Mar 2008 02:34:55 -0000 1.10
***************
*** 84,87 ****
--- 84,92 ----
// failure)
Device* GetDevice(player_devaddr_t addr, bool lookup_remote=true);
+
+ // find a device, based on id, and return the pointer (or NULL on
+ // failure)
+ Device* GetDevice(const char* str_addr,
+ bool lookup_remote=true);
// Get the first device entry.
Index: configfile.h
===================================================================
RCS file: /cvsroot/playerstage/code/player/libplayercore/configfile.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** configfile.h 10 Jul 2007 09:01:51 -0000 1.12
--- configfile.h 7 Mar 2008 02:34:55 -0000 1.13
***************
*** 190,193 ****
--- 190,196 ----
public: ConfigFile(const char* _default_host, uint32_t _default_robot);
+ /// Alternate constructor, used when not loading from a file
+ public: ConfigFile();
+
/// @brief Standard destructor
public: ~ConfigFile();
***************
*** 201,204 ****
--- 204,219 ----
public: bool Load(const char *filename);
+ /// @brief Add a (name,value) pair directly into the database, without
+ /// reading from a file. The (name,value) goes into the "global" section.
+ /// Can be called multiple times with different index to create a tuple
+ /// field.
+ /// @param index Index of the value within the field (0 unless the field
+ /// is a tuple)
+ /// @param name Name of the field
+ /// @param value Value to be assigned
+ public: void InsertFieldValue(int index,
+ const char* name,
+ const char* value);
+
// Save config back into file
// Set filename to NULL to save back into the original file
Index: configfile.cc
===================================================================
RCS file: /cvsroot/playerstage/code/player/libplayercore/configfile.cc,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** configfile.cc 13 Aug 2007 07:06:03 -0000 1.19
--- configfile.cc 7 Mar 2008 02:34:55 -0000 1.20
***************
*** 117,120 ****
--- 117,129 ----
}
+ /// Alternate constructor, used when not loading from a file
+ ConfigFile::ConfigFile()
+ {
+ this->default_host = 0;
+ this->default_robot = 0;
+ this->filename = strdup("");
+ this->InitFields();
+ }
+
void
ConfigFile::InitFields()
***************
*** 231,234 ****
--- 240,256 ----
}
+ ///////////////////////////////////////////////////////////////////////////
+ /// Add a (name,value) pair directly into the database, without
+ /// reading from a file. The (name,value) goes into the "global" section.
+ void ConfigFile::InsertFieldValue(int index,
+ const char* name,
+ const char* value)
+ {
+ // AddField checks whether the field already exists
+ int field = this->AddField(-1,name,0);
+ this->AddToken(ConfigFile::TokenWord, value, 0);
+ this->AddFieldValue(field, index, this->token_count-1);
+ }
+
///////////////////////////////////////////////////////////////////////////
***************
*** 1945,1949 ****
if ((prop = GetField(section, name)) < 0)
{
! CONFIG_ERR1("missing field [%s]", this->fields[prop].line, name);
return -1;
}
--- 1967,1971 ----
if ((prop = GetField(section, name)) < 0)
{
! CONFIG_ERR1("missing field [%s]", 0, name);
return -1;
}
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit